#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
char Find_CharA(long);
char *malloc(int);
long *powmodA(long *, long, long);
int /*<<< orphan*/ printf(char *, ...);
char *decrypt_messageA(long *M, long d, long n) {
  printf("\n\nMessage a recu : ");
  int i;
  for (i = 0; i < 4; ++i) {
    printf("%ld", M[i]);
    if (i < 3) {
      printf(", ");
    }
  }
  printf("\n");
  printf("--------------------Derypter--------------------\n");
  long *D = powmodA(M, d, n);
  char *caractere = malloc(4 * sizeof(char));
  int j;
  printf("Message decrypte : ");
  for (j = 0; j < 4; ++j) {
    caractere[j] = Find_CharA(D[j]);
    printf("%c", caractere[j]);
    if (j < 3) {
      printf(", ");
    }
  }
  printf("\n");
  return caractere;
}


x86 assembly (clang, -O0):
<decrypt_messageA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11b8 <decrypt_messageA+0x78>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x1c(%rbp)
jge    11a5 <decrypt_messageA+0x65>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <decrypt_messageA+0x6a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1169 <decrypt_messageA+0x29>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <powmodA@plt>
mov    %rax,-0x28(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    1279 <decrypt_messageA+0x139>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <Find_CharA@plt>
mov    %al,%dl
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x34(%rbp)
jge    1266 <decrypt_messageA+0x126>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126b <decrypt_messageA+0x12b>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    120c <decrypt_messageA+0xcc>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt_messageA>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rsi
lea    0xe8a(%rip),%r13
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe7d(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rbx),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1080 <powmodA@plt>
mov    %rax,%r15
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15),%rdi
call   1070 <Find_CharA@plt>
mov    %al,(%rbx)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r15),%rdi
call   1070 <Find_CharA@plt>
mov    %al,0x1(%rbx)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%r15),%rdi
call   1070 <Find_CharA@plt>
mov    %al,0x2(%rbx)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%r15),%rdi
call   1070 <Find_CharA@plt>
mov    %al,0x3(%rbx)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0A\0AMessage a recu : \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [3 x i8] c", \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [50 x i8] c"--------------------Derypter--------------------\0A\00"
@.str.5 = [20 x i8] c"Message decrypte : \00"
@.str.6 = [3 x i8] c"%c\00"
define i8* @decrypt_messageA(i64* %0, i64 %1, i64 %2) {
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64*
%9 = alloca i8*
%10 = alloca i32
store i64* %0, i64** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %12
12: ; preds = %27, %3
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %30
15: ; preds = %12
%16 = load i64*, i64** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i64, i64* %16, i64 %18
%20 = load i64, i64* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %20)
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 3
br i1 %23, label %24, label %26
24: ; preds = %15
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %15
br label %27
27: ; preds = %26
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %12
30: ; preds = %12
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%33 = load i64*, i64** %4
%34 = load i64, i64* %5
%35 = load i64, i64* %6
%36 = call i64* @powmodA(i64* %33, i64 %34, i64 %35)
store i64* %36, i64** %8
%37 = call i8* @malloc(i32 4)
store i8* %37, i8** %9
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %10
br label %39
39: ; preds = %65, %30
%40 = load i32, i32* %10
%41 = icmp slt i32 %40, 4
br i1 %41, label %42, label %68
42: ; preds = %39
%43 = load i64*, i64** %8
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i64, i64* %43, i64 %45
%47 = load i64, i64* %46
%48 = call signext i8 @Find_CharA(i64 %47)
%49 = load i8*, i8** %9
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
store i8 %48, i8* %52
%53 = load i8*, i8** %9
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %10
%61 = icmp slt i32 %60, 3
br i1 %61, label %62, label %64
62: ; preds = %42
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %64
64: ; preds = %62, %42
br label %65
65: ; preds = %64
%66 = load i32, i32* %10
%67 = add nsw i32 %66, 1
store i32 %67, i32* %10
br label %39
68: ; preds = %39
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%70 = load i8*, i8** %9
ret i8* %70
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0A\0AMessage a recu : \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [3 x i8] c", \00"
@.str.5 = [20 x i8] c"Message decrypte : \00"
@str = [49 x i8] c"--------------------Derypter--------------------\00"
define noalias i8* @decrypt_messageA(i64* %0, i64 %1, i64 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = load i64, i64* %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds i64, i64* %0, i64 1
%9 = load i64, i64* %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %9)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds i64, i64* %0, i64 2
%13 = load i64, i64* %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds i64, i64* %0, i64 3
%17 = load i64, i64* %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %17)
%19 = tail call i32 @putchar(i32 10)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%21 = tail call i64* @powmodA(i64* %0, i64 %1, i64 %2)
%22 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%24 = load i64, i64* %21
%25 = tail call signext i8 @Find_CharA(i64 %24)
store i8 %25, i8* %22
%26 = sext i8 %25 to i32
%27 = tail call i32 @putchar(i32 %26)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%29 = getelementptr inbounds i64, i64* %21, i64 1
%30 = load i64, i64* %29
%31 = tail call signext i8 @Find_CharA(i64 %30)
%32 = getelementptr inbounds i8, i8* %22, i64 1
store i8 %31, i8* %32
%33 = sext i8 %31 to i32
%34 = tail call i32 @putchar(i32 %33)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%36 = getelementptr inbounds i64, i64* %21, i64 2
%37 = load i64, i64* %36
%38 = tail call signext i8 @Find_CharA(i64 %37)
%39 = getelementptr inbounds i8, i8* %22, i64 2
store i8 %38, i8* %39
%40 = sext i8 %38 to i32
%41 = tail call i32 @putchar(i32 %40)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%43 = getelementptr inbounds i64, i64* %21, i64 3
%44 = load i64, i64* %43
%45 = tail call signext i8 @Find_CharA(i64 %44)
%46 = getelementptr inbounds i8, i8* %22, i64 3
store i8 %45, i8* %46
%47 = sext i8 %45 to i32
%48 = tail call i32 @putchar(i32 %47)
%49 = tail call i32 @putchar(i32 10)
ret i8* %22
}