#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 */
int check_password(char *, char *);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  if ((argc != 2) || ((argc == 2) && strlen(argv[1]) > 10)) {
    printf("Syntax:\ttimeside <pin>\n");
    printf("\tWhere <pin> is a number up to 10 digits.\n");
    printf("\tReturns 1 if the pin is correct, 0 o/w.\n");
  } else {
    if (check_password("passfile.dat", argv[1]) == true) {
      printf("1\n");
    } else {
      printf("0\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1170 <main+0x40>
cmpl   $0x2,-0x8(%rbp)
jne    1199 <main+0x69>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
cmp    $0xa,%eax
jle    1199 <main+0x69>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
jmp    11d8 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xec5(%rip),%rdi
call   1050 <check_password@plt>
cmp    $0x1,%eax
jne    11c7 <main+0x97>
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
jmp    11d3 <main+0xa3>
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
jmp    11d8 <main+0xa8>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    1147 <main+0x17>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1040 <strlen@plt>
cmp    $0xb,%eax
jl     1168 <main+0x38>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xeec(%rip),%rdi
jmp    118d <main+0x5d>
mov    0x8(%rbx),%rsi
lea    0xe8d(%rip),%rdi
call   1050 <check_password@plt>
cmp    $0x1,%eax
lea    0xe8d(%rip),%rax
lea    0xe84(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Syntax:\09timeside <pin>\0A\00"
@.str.1 = [43 x i8] c"\09Where <pin> is a number up to 10 digits.\0A\00"
@.str.2 = [42 x i8] c"\09Returns 1 if the pin is correct, 0 o/w.\0A\00"
@.str.3 = [13 x i8] c"passfile.dat\00"
@.str.4 = [3 x i8] c"1\0A\00"
@.str.5 = [3 x i8] c"0\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 2
br i1 %7, label %17, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strlen(i8* %14)
%16 = icmp sgt i32 %15, 10
br i1 %16, label %17, label %21
17: ; preds = %11, %2
%18 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %32
21: ; preds = %11, %8
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @check_password(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %31
29: ; preds = %21
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
br label %32
32: ; preds = %31, %17
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [13 x i8] c"passfile.dat\00"
@str = [2 x i8] c"0\00"
@str.6 = [2 x i8] c"1\00"
@str.7 = [23 x i8] c"Syntax:\09timeside <pin>\00"
@str.8 = [42 x i8] c"\09Where <pin> is a number up to 10 digits.\00"
@str.9 = [41 x i8] c"\09Returns 1 if the pin is correct, 0 o/w.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strlen(i8* %6)
%8 = icmp sgt i32 %7, 10
br i1 %8, label %9, label %12
9: ; preds = %4, %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.7, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.8, i64 0, i64 0))
br label %17
12: ; preds = %4
%13 = load i8*, i8** %5
%14 = tail call i32 @check_password(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = icmp eq i32 %14, 1
%16 = select i1 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0)
br label %17
17: ; preds = %12, %9
%18 = phi i8* [ getelementptr inbounds ([41 x i8], [41 x i8]* @str.9, i64 0, i64 0), %9 ], [ %16, %12 ]
%19 = tail call i32 @puts(i8* dereferenceable(1) %18)
ret i32 0
}