#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*/ MD5_CTX;

/* Variables and functions */
int MD5_DIGEST_LENGTH;
int /*<<< orphan*/ MD5_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int main(int argc, const char *argv[]) {
  unsigned char buffer[MD5_DIGEST_LENGTH];
  char password[9];
  int index = 0;
  int actualChar = 0;
  while (actualChar < 8) {
    char buff[19];
    strncpy(buff, argv[1], 9);
    char entier[9];
    sprintf(entier, "%d", index);
    strncat(buff, entier, 9);
    char result[7];
    MD5_CTX c;
    MD5_Init(&c);
    MD5_Update(&c, buff, strlen(buff));
    MD5_Final(buffer, &c);
    for (int i = 0; i < 3; i++) {
      sprintf(&(result[2 * i]), "%02x", buffer[i]);
    }
    if (strncmp(result, "00000", 5) == 0) {
      password[actualChar] = result[5];
      actualChar++;
    }
    index++;
  }
  password[8] = 0;
  printf("%s\n", password);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    12e9 <main+0x159>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x9,%edx
call   1030 <strncpy@plt>
lea    -0x59(%rbp),%rdi
mov    -0x30(%rbp),%eax
lea    0xdef(%rip),%rsi
movzbl %al,%edx
call   10a0 <sprintf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x59(%rbp),%rsi
mov    $0x9,%edx
call   1080 <strncat@plt>
lea    -0x64(%rbp),%rdi
call   1090 <MD5_Init@plt>
lea    -0x50(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
lea    -0x64(%rbp),%rdi
call   10b0 <MD5_Update@plt>
mov    -0x70(%rbp),%rdi
lea    -0x64(%rbp),%rsi
call   1050 <MD5_Final@plt>
movl   $0x0,-0x68(%rbp)
cmpl   $0x3,-0x68(%rbp)
jge    12a8 <main+0x118>
mov    -0x70(%rbp),%rax
mov    -0x68(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
lea    -0x60(%rbp),%rdi
add    %rcx,%rdi
movslq -0x68(%rbp),%rcx
lea    0xd72(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   10a0 <sprintf@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1268 <main+0xd8>
lea    -0x60(%rbp),%rdi
lea    0xd55(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    12db <main+0x14b>
mov    -0x5b(%rbp),%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x29(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11e3 <main+0x53>
movb   $0x0,-0x21(%rbp)
lea    -0x29(%rbp),%rsi
lea    0xd16(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,-0x50(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
xor    %r12d,%r12d
xor    %ecx,%ecx
jmp    11ef <main+0x5f>
cs nopw 0x0(%rax,%rax,1)
movzbl -0x2a(%rbp),%eax
mov    -0x38(%rbp),%rcx
movslq %ecx,%rcx
mov    %al,-0x41(%rbp,%rcx,1)
add    $0x1,%ecx
add    $0x1,%r12b
cmp    $0x8,%ecx
jge    12c2 <main+0x132>
mov    %rcx,-0x38(%rbp)
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x70(%rbp),%r15
mov    %r15,%rdi
mov    $0x9,%edx
call   1030 <strncpy@plt>
movzbl %r12b,%edx
lea    -0x5d(%rbp),%r14
mov    %r14,%rdi
lea    0xde2(%rip),%rsi
call   10a0 <sprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
call   1080 <strncat@plt>
lea    -0x54(%rbp),%rbx
mov    %rbx,%rdi
call   1090 <MD5_Init@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   10b0 <MD5_Update@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <MD5_Final@plt>
movzbl 0x0(%r13),%edx
lea    -0x2f(%rbp),%r14
mov    %r14,%rdi
lea    0xd91(%rip),%rbx
mov    %rbx,%rsi
call   10a0 <sprintf@plt>
movzbl 0x1(%r13),%edx
lea    -0x2d(%rbp),%rdi
mov    %rbx,%rsi
call   10a0 <sprintf@plt>
movzbl 0x2(%r13),%edx
lea    -0x2b(%rbp),%rdi
mov    %rbx,%rsi
call   10a0 <sprintf@plt>
mov    %r14,%rdi
lea    0xd62(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11d0 <main+0x40>
mov    -0x38(%rbp),%rcx
jmp    11e2 <main+0x52>
movb   $0x0,-0x39(%rbp)
lea    0xd41(%rip),%rdi
lea    -0x41(%rbp),%rsi
call   1070 <printf@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MD5_DIGEST_LENGTH = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [6 x i8] c"00000\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [9 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca [19 x i8]
%12 = alloca [9 x i8]
%13 = alloca [7 x i8]
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* @MD5_DIGEST_LENGTH
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %6
%19 = alloca i8, i64 %17
store i64 %17, i64* %7
store i32 0, i32* %9
store i32 0, i32* %10
br label %20
20: ; preds = %70, %2
%21 = load i32, i32* %10
%22 = icmp slt i32 %21, 8
br i1 %22, label %23, label %73
23: ; preds = %20
%24 = getelementptr inbounds [19 x i8], [19 x i8]* %11, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @strncpy(i8* %24, i8* %27, i32 9)
%29 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 0
%30 = load i32, i32* %9
%31 = trunc i32 %30 to i8
%32 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %31)
%33 = getelementptr inbounds [19 x i8], [19 x i8]* %11, i64 0, i64 0
%34 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 0
%35 = call i32 @strncat(i8* %33, i8* %34, i32 9)
%36 = call i32 @MD5_Init(i32* %14)
%37 = getelementptr inbounds [19 x i8], [19 x i8]* %11, i64 0, i64 0
%38 = getelementptr inbounds [19 x i8], [19 x i8]* %11, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = call i32 @MD5_Update(i32* %14, i8* %37, i32 %39)
%41 = call i32 @MD5_Final(i8* %19, i32* %14)
store i32 0, i32* %15
br label %42
42: ; preds = %55, %23
%43 = load i32, i32* %15
%44 = icmp slt i32 %43, 3
br i1 %44, label %45, label %58
45: ; preds = %42
%46 = load i32, i32* %15
%47 = mul nsw i32 2, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [7 x i8], [7 x i8]* %13, i64 0, i64 %48
%50 = load i32, i32* %15
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %19, i64 %51
%53 = load i8, i8* %52
%54 = call i32 @sprintf(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %53)
br label %55
55: ; preds = %45
%56 = load i32, i32* %15
%57 = add nsw i32 %56, 1
store i32 %57, i32* %15
br label %42
58: ; preds = %42
%59 = getelementptr inbounds [7 x i8], [7 x i8]* %13, i64 0, i64 0
%60 = call i64 @strncmp(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %70
62: ; preds = %58
%63 = getelementptr inbounds [7 x i8], [7 x i8]* %13, i64 0, i64 5
%64 = load i8, i8* %63
%65 = load i32, i32* %10
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 %66
store i8 %64, i8* %67
%68 = load i32, i32* %10
%69 = add nsw i32 %68, 1
store i32 %69, i32* %10
br label %70
70: ; preds = %62, %58
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
br label %20
73: ; preds = %20
%74 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 8
store i8 0, i8* %74
%75 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%76 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %75)
store i32 0, i32* %3
%77 = load i8*, i8** %6
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [6 x i8] c"00000\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [9 x i8]
%4 = alloca [19 x i8]
%5 = alloca [9 x i8]
%6 = alloca [7 x i8]
%7 = alloca i32
%8 = load i32, i32* @MD5_DIGEST_LENGTH
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%16 = bitcast i32* %7 to i8*
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 5
%18 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 2
%19 = getelementptr inbounds i8, i8* %10, i64 1
%20 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 4
%21 = getelementptr inbounds i8, i8* %10, i64 2
br label %22
22: ; preds = %2, %47
%23 = phi i32 [ 0, %2 ], [ %48, %47 ]
%24 = phi i32 [ 0, %2 ], [ %49, %47 ]
%25 = load i8*, i8** %13
%26 = call i32 @strncpy(i8* %12, i8* %25, i32 9)
%27 = trunc i32 %24 to i8
%28 = call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %27)
%29 = call i32 @strncat(i8* %12, i8* %14, i32 9)
%30 = call i32 @MD5_Init(i32* %7)
%31 = call i32 @strlen(i8* %12)
%32 = call i32 @MD5_Update(i32* %7, i8* %12, i32 %31)
%33 = call i32 @MD5_Final(i8* %10, i32* %7)
%34 = load i8, i8* %10
%35 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %34)
%36 = load i8, i8* %19
%37 = call i32 @sprintf(i8* %18, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %36)
%38 = load i8, i8* %21
%39 = call i32 @sprintf(i8* %20, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %38)
%40 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %22
%43 = load i8, i8* %17
%44 = sext i32 %23 to i64
%45 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 %44
store i8 %43, i8* %45
%46 = add nsw i32 %23, 1
br label %47
47: ; preds = %42, %22
%48 = phi i32 [ %46, %42 ], [ %23, %22 ]
%49 = add nuw nsw i32 %24, 1
%50 = icmp slt i32 %48, 8
br i1 %50, label %22, label %51
51: ; preds = %47
%52 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 8
store i8 0, i8* %52
%53 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %11)
ret i32 0
}