int main(int argc, char **argv) {
  int first[10] = {0}, second[10] = {0}, third = -1;
  if (argc == 2) {
    sscanf(argv[1], "%2d", &third);
    if (third == 0 && argv[1][0] != '0')
      third = -1;
  }
  if (!validate_range(third)) {
    printf("Usage: ./lockpro THIRD\n");
    printf("THIRD should be an integer between %d and %d.\n", 0, 39);
    return 1;
  }
  first[0] = third % 4;
  generate_numbers(first);
  second[0] = (first[0] + 2) % 4;
  generate_numbers(second);
  print_first(first);
  print_second(second, third);
  print_combinations(first, second, third);
  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)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movl   $0xffffffff,-0x74(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    120e <main+0x8e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe27(%rip),%rsi
lea    -0x74(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmpl   $0x0,-0x74(%rbp)
jne    1209 <main+0x89>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     1209 <main+0x89>
movl   $0xffffffff,-0x74(%rbp)
jmp    120e <main+0x8e>
mov    -0x74(%rbp),%edi
mov    $0x0,%al
call   1060 <validate_range@plt>
cmp    $0x0,%eax
jne    1250 <main+0xd0>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde6(%rip),%rdi
xor    %esi,%esi
mov    $0x27,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b7 <main+0x137>
mov    -0x74(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x40(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x0,%al
call   1030 <generate_numbers@plt>
mov    -0x40(%rbp),%eax
add    $0x2,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x70(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x0,%al
call   1030 <generate_numbers@plt>
lea    -0x40(%rbp),%rdi
mov    $0x0,%al
call   1090 <print_first@plt>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
mov    $0x0,%al
call   1080 <print_second@plt>
lea    -0x40(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
mov    $0x0,%al
call   10a0 <print_combinations@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %edi,%eax
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movq   $0x0,0x60(%rsp)
movl   $0xffffffff,0xc(%rsp)
ff
mov    $0xffffffff,%edi
cmp    $0x2,%eax
jne    1202 <main+0x82>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe2d(%rip),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jne    1202 <main+0x82>
mov    0x8(%rbx),%rax
cmpb   $0x30,(%rax)
mov    $0x0,%edi
je     1202 <main+0x82>
movl   $0xffffffff,0xc(%rsp)
ff
mov    $0xffffffff,%edi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <validate_range@plt>
test   %eax,%eax
je     128a <main+0x10a>
mov    0xc(%rsp),%eax
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <generate_numbers@plt>
mov    0x10(%rsp),%eax
lea    0x2(%rax),%ecx
lea    0x5(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xfffffffc,%edx
neg    %edx
add    %edx,%eax
add    $0x2,%eax
mov    %eax,0x40(%rsp)
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <generate_numbers@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <print_first@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <print_second@plt>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <print_combinations@plt>
jmp    12b0 <main+0x130>
lea    0xda2(%rip),%rdi
call   1040 <puts@plt>
lea    0xd67(%rip),%rdi
xor    %esi,%esi
mov    $0x27,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%2d\00"
@.str.1 = [24 x i8] c"Usage: ./lockpro THIRD\0A\00"
@.str.2 = [47 x i8] c"THIRD should be an integer between %d and %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i32]
%7 = alloca [10 x i32]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [10 x i32]* %6 to i8*
%10 = bitcast [10 x i32]* %7 to i8*
store i32 -1, i32* %8
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %30
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 (i8*, i8*, ...) @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %8)
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %13
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 48
br i1 %27, label %28, label %29
28: ; preds = %20
store i32 -1, i32* %8
br label %29
29: ; preds = %28, %20, %13
br label %30
30: ; preds = %29, %2
%31 = load i32, i32* %8
%32 = call i32 (i32, ...) bitcast (i32 (...)* @validate_range to i32 (i32, ...)*)(i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 39)
store i32 1, i32* %3
br label %59
37: ; preds = %30
%38 = load i32, i32* %8
%39 = srem i32 %38, 4
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
store i32 %39, i32* %40
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%42 = call i32 (i32*, ...) bitcast (i32 (...)* @generate_numbers to i32 (i32*, ...)*)(i32* %41)
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 2
%46 = srem i32 %45, 4
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
store i32 %46, i32* %47
%48 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%49 = call i32 (i32*, ...) bitcast (i32 (...)* @generate_numbers to i32 (i32*, ...)*)(i32* %48)
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%51 = call i32 (i32*, ...) bitcast (i32 (...)* @print_first to i32 (i32*, ...)*)(i32* %50)
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%53 = load i32, i32* %8
%54 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @print_second to i32 (i32*, i32, ...)*)(i32* %52, i32 %53)
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%56 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%57 = load i32, i32* %8
%58 = call i32 (i32*, i32*, i32, ...) bitcast (i32 (...)* @print_combinations to i32 (i32*, i32*, i32, ...)*)(i32* %55, i32* %56, i32 %57)
store i32 0, i32* %3
br label %59
59: ; preds = %37, %34
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
@.str = [4 x i8] c"%2d\00"
@.str.2 = [47 x i8] c"THIRD should be an integer between %d and %d.\0A\00"
@str = [23 x i8] c"Usage: ./lockpro THIRD\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i32]
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = bitcast [10 x i32]* %3 to i8*
%7 = bitcast [10 x i32]* %4 to i8*
%8 = bitcast i32* %5 to i8*
store i32 -1, i32* %5
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 (i8*, i8*, ...) @sscanf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = load i8*, i8** %11
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 48
br i1 %19, label %21, label %20
20: ; preds = %16
store i32 -1, i32* %5
br label %21
21: ; preds = %10, %16, %20, %2
%22 = phi i32 [ %14, %10 ], [ 0, %16 ], [ -1, %20 ], [ -1, %2 ]
%23 = call i32 (i32, ...) bitcast (i32 (...)* @validate_range to i32 (i32, ...)*)(i32 %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 39)
br label %43
28: ; preds = %21
%29 = load i32, i32* %5
%30 = srem i32 %29, 4
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 %30, i32* %31
%32 = call i32 (i32*, ...) bitcast (i32 (...)* @generate_numbers to i32 (i32*, ...)*)(i32* %31)
%33 = load i32, i32* %31
%34 = add nsw i32 %33, 2
%35 = srem i32 %34, 4
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
store i32 %35, i32* %36
%37 = call i32 (i32*, ...) bitcast (i32 (...)* @generate_numbers to i32 (i32*, ...)*)(i32* %36)
%38 = call i32 (i32*, ...) bitcast (i32 (...)* @print_first to i32 (i32*, ...)*)(i32* %31)
%39 = load i32, i32* %5
%40 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @print_second to i32 (i32*, i32, ...)*)(i32* %36, i32 %39)
%41 = load i32, i32* %5
%42 = call i32 (i32*, i32*, i32, ...) bitcast (i32 (...)* @print_combinations to i32 (i32*, i32*, i32, ...)*)(i32* %31, i32* %36, i32 %41)
br label %43
43: ; preds = %28, %25
%44 = phi i32 [ 0, %28 ], [ 1, %25 ]
ret i32 %44
}