#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 */
typedef int /*<<< orphan*/ secret;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  char mpd[5] = "";
  char in[5] = "";
  char secret[12] = "Mbcpsbupjsf";
  char realsecret[12] = "";
  int i = 0;
  for (i = 0; i <= sizeof(secret); i++) {
    realsecret[i] = secret[i] - 1;
  }
  i = 11;
  realsecret[i] = '\0';
  for (i = 0; i <= 4; i++) {
    mpd[i] = rand() % 9 + 49;
  }
  mpd[4] = '\0';
  printf("Entrez le mot de passe (4 chiffres) pour decouvrir le secret !\n");
  while (1) {
    fflush(stdin);
    gets(in);
    if (strcmp(in, mpd) == 0) {
      printf("Felicitation, le secret est '%s'", realsecret);
      return 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    -0x9(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
lea    -0xe(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
mov    0xe3a(%rip),%rax
mov    %rax,-0x1a(%rbp)
mov    0xe38(%rip),%eax
mov    %eax,-0x12(%rbp)
lea    -0x26(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    $0xc,%rax
ja     1223 <main+0xa3>
movslq -0x2c(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%eax
sub    $0x1,%eax
mov    %al,%cl
movslq -0x2c(%rbp),%rax
mov    %cl,-0x26(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11f1 <main+0x71>
movl   $0xb,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
movb   $0x0,-0x26(%rbp,%rax,1)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jg     126e <main+0xee>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
add    $0x31,%edx
mov    %dl,%cl
movslq -0x2c(%rbp),%rax
mov    %cl,-0x9(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    123a <main+0xba>
movb   $0x0,-0x5(%rbp)
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    -0xe(%rbp),%rdi
call   1080 <gets@plt>
lea    -0xe(%rbp),%rdi
lea    -0x9(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12c8 <main+0x148>
lea    -0x26(%rbp),%rsi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
jmp    1280 <main+0x100>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movb   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movabs $0x6f7461726f62614c,%rax
61 74 6f
mov    %rax,0x14(%rsp)
movl   $0x657269,0x1c(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0x7(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0x8(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0x9(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0xa(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
movb   $0x0,0xb(%rsp)
lea    0xdb3(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d6e(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0x7(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15),%edi
call   1090 <fflush@plt>
mov    %rbx,%rdi
call   1080 <gets@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1290 <main+0x110>
lea    0xd49(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.secret = [12 x i8] c"Mbcpsbupjsf\00"
@.str = [64 x i8] c"Entrez le mot de passe (4 chiffres) pour decouvrir le secret !\0A\00"
@stdin = global i32 0
@.str.1 = [33 x i8] c"Felicitation, le secret est '%s'\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = alloca [12 x i8]
%5 = alloca [12 x i8]
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
%9 = bitcast [5 x i8]* %2 to i8*
%10 = bitcast [5 x i8]* %3 to i8*
%11 = bitcast [12 x i8]* %4 to i8*
%12 = bitcast [12 x i8]* %5 to i8*
store i32 0, i32* %6
store i32 0, i32* %6
br label %13
13: ; preds = %28, %0
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = icmp ule i64 %15, 12
br i1 %16, label %17, label %31
17: ; preds = %13
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 1
%24 = trunc i32 %23 to i8
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 %26
store i8 %24, i8* %27
br label %28
28: ; preds = %17
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %13
31: ; preds = %13
store i32 11, i32* %6
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 %33
store i8 0, i8* %34
store i32 0, i32* %6
br label %35
35: ; preds = %46, %31
%36 = load i32, i32* %6
%37 = icmp sle i32 %36, 4
br i1 %37, label %38, label %49
38: ; preds = %35
%39 = call i32 (...) @rand()
%40 = srem i32 %39, 9
%41 = add nsw i32 %40, 49
%42 = trunc i32 %41 to i8
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %44
store i8 %42, i8* %45
br label %46
46: ; preds = %38
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %35
49: ; preds = %35
%50 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 4
store i8 0, i8* %50
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
br label %52
52: ; preds = %49, %64
%53 = load i32, i32* @stdin
%54 = call i32 @fflush(i32 %53)
%55 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%56 = call i32 @gets(i8* %55)
%57 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%58 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%59 = call i64 @strcmp(i8* %57, i8* %58)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %52
%62 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %62)
ret i32 0
64: ; preds = %52
br label %52
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [33 x i8] c"Felicitation, le secret est '%s'\00"
@str = [63 x i8] c"Entrez le mot de passe (4 chiffres) pour decouvrir le secret !\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = alloca [12 x i8]
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
store i8 76, i8* %8
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 1
store i8 97, i8* %9
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 2
store i8 98, i8* %10
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 3
store i8 111, i8* %11
%12 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 4
store i8 114, i8* %12
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 5
store i8 97, i8* %13
%14 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 6
store i8 116, i8* %14
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 7
store i8 111, i8* %15
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 8
store i8 105, i8* %16
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 9
store i8 114, i8* %17
%18 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 10
store i8 101, i8* %18
%19 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 11
store i8 0, i8* %19
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 9
%22 = trunc i32 %21 to i8
%23 = add nsw i8 %22, 49
store i8 %23, i8* %6
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 9
%26 = trunc i32 %25 to i8
%27 = add nsw i8 %26, 49
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
store i8 %27, i8* %28
%29 = tail call i32 (...) @rand()
%30 = srem i32 %29, 9
%31 = trunc i32 %30 to i8
%32 = add nsw i8 %31, 49
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
store i8 %32, i8* %33
%34 = tail call i32 (...) @rand()
%35 = srem i32 %34, 9
%36 = trunc i32 %35 to i8
%37 = add nsw i8 %36, 49
%38 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 3
store i8 %37, i8* %38
%39 = tail call i32 (...) @rand()
%40 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 4
store i8 0, i8* %40
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
br label %42
42: ; preds = %42, %0
%43 = load i32, i32* @stdin
%44 = call i32 @fflush(i32 %43)
%45 = call i32 @gets(i8* %7)
%46 = call i64 @strcmp(i8* %7, i8* %6)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %42
48: ; preds = %42
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %8)
ret i32 0
}