#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 */
scalar_t__ check(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ setuid(int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  char user_pass[256];
  printf("Password: ");
  scanf("%255s", user_pass);
  if (check(user_pass, "ThisIsALongPassword")) {
    printf("Win!\n");
    setuid(0);
    system("/bin/sh");
  } else {
    printf("Fail!\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <check@plt>
cmp    $0x0,%rax
je     11c9 <main+0x79>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <setuid@plt>
lea    0xe6c(%rip),%rdi
call   1030 <system@plt>
jmp    11d5 <main+0x85>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
lea    0xe90(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1070 <check@plt>
test   %rax,%rax
je     11bb <main+0x5b>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <setuid@plt>
lea    0xe71(%rip),%rdi
call   1040 <system@plt>
jmp    11c7 <main+0x67>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Password: \00"
@.str.1 = [6 x i8] c"%255s\00"
@.str.2 = [20 x i8] c"ThisIsALongPassword\00"
@.str.3 = [6 x i8] c"Win!\0A\00"
@.str.4 = [8 x i8] c"/bin/sh\00"
@.str.5 = [7 x i8] c"Fail!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = call i64 @check(i8* %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @setuid(i32 0)
%16 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %19
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [11 x i8] c"Password: \00"
@.str.1 = [6 x i8] c"%255s\00"
@.str.2 = [20 x i8] c"ThisIsALongPassword\00"
@.str.4 = [8 x i8] c"/bin/sh\00"
@str = [6 x i8] c"Fail!\00"
@str.6 = [5 x i8] c"Win!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = call i64 @check(i8* %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.6, i64 0, i64 0))
%11 = call i32 @setuid(i32 0)
%12 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %15
13: ; preds = %2
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
ret i32 0
}