#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 /*<<< orphan*/ O_RDONLY;
int key1();
int key2();
int key3();
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main() {
  int key = 0;
  printf("Daddy has very strong arm! : ");
  scanf("%d", &key);
  if ((key1() + key2() + key3()) == key) {
    printf("Congratz!\n");
    int fd = open("flag", O_RDONLY);
    char buf[100];
    int r = read(fd, buf, 100);
    write(0, buf, r);
  } else {
    printf("I have strong leg :P\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
lea    0xe72(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1090 <key1@plt>
mov    %eax,-0x7c(%rbp)
mov    $0x0,%al
call   1040 <key2@plt>
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x78(%rbp)
mov    $0x0,%al
call   1080 <key3@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
add    %ecx,%eax
cmp    -0x8(%rbp),%eax
jne    1232 <main+0xb2>
lea    0xe33(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
lea    0xe29(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x64,%edx
call   1060 <read@plt>
mov    %eax,-0x74(%rbp)
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
xor    %edi,%edi
call   1030 <write@plt>
jmp    123e <main+0xbe>
lea    0xdf8(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x78,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe5b(%rip),%rdi
call   1060 <printf@plt>
lea    0xe6d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
call   10a0 <key1@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <key2@plt>
mov    %eax,%ebp
add    %ebx,%ebp
xor    %eax,%eax
call   1090 <key3@plt>
add    %ebp,%eax
cmp    0xc(%rsp),%eax
jne    1221 <main+0x91>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
lea    0xe27(%rip),%rdi
call   10b0 <open@plt>
lea    0x10(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1070 <read@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
jmp    122d <main+0x9d>
lea    0xdfe(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Daddy has very strong arm! : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Congratz!\0A\00"
@.str.3 = [5 x i8] c"flag\00"
@O_RDONLY = global i32 0
@.str.4 = [22 x i8] c"I have strong leg :P\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (...) @key1()
%9 = call i32 (...) @key2()
%10 = add nsw i32 %8, %9
%11 = call i32 (...) @key3()
%12 = add nsw i32 %10, %11
%13 = load i32, i32* %2
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %25
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* @O_RDONLY
%18 = call i32 @open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %17)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%21 = call i32 @read(i32 %19, i8* %20, i32 100)
store i32 %21, i32* %5
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%23 = load i32, i32* %5
%24 = call i32 @write(i32 0, i8* %22, i32 %23)
br label %27
25: ; preds = %0
%26 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Daddy has very strong arm! : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"flag\00"
@O_RDONLY = global i32 0
@str = [21 x i8] c"I have strong leg :P\00"
@str.5 = [10 x i8] c"Congratz!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = call i32 (...) @key1()
%7 = call i32 (...) @key2()
%8 = add nsw i32 %7, %6
%9 = call i32 (...) @key3()
%10 = add nsw i32 %8, %9
%11 = load i32, i32* %1
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
%15 = load i32, i32* @O_RDONLY
%16 = call i32 @open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = call i32 @read(i32 %16, i8* %17, i32 100)
%19 = call i32 @write(i32 0, i8* %17, i32 %18)
br label %22
20: ; preds = %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %13
ret i32 0
}