#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*/ execv(char *, char **);
int /*<<< orphan*/ setresuid(int, int, int);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (strcmp(argv[1], "1234") == 0) {
    char *argv[] = {"/bin/sh"};
    setresuid(2007, 2007, 2007);
    execv("/bin/sh", argv);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeab(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118d <main+0x5d>
mov    0x2cad(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x7d7,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1030 <setresuid@plt>
lea    -0x18(%rbp),%rsi
lea    0xe7d(%rip),%rdi
call   1050 <execv@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
lea    0xec0(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1177 <main+0x47>
lea    0xeb4(%rip),%rbx
mov    %rbx,0x8(%rsp)
mov    $0x7d7,%edi
mov    $0x7d7,%esi
mov    $0x7d7,%edx
call   1030 <setresuid@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <execv@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"1234\00"
@.str.1 = [8 x i8] c"/bin/sh\00"
@__const.main.argv = [1 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0)]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = bitcast [1 x i8*]* %6 to i8*
%14 = call i32 @setresuid(i32 2007, i32 2007, i32 2007)
%15 = getelementptr inbounds [1 x i8*], [1 x i8*]* %6, i64 0, i64 0
%16 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %15)
br label %17
17: ; preds = %12, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"1234\00"
@.str.1 = [8 x i8] c"/bin/sh\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x i8*]
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = bitcast [1 x i8*]* %3 to i8*
%10 = bitcast [1 x i8*]* %3 to i64*
store i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64* %10
%11 = tail call i32 @setresuid(i32 2007, i32 2007, i32 2007)
%12 = getelementptr inbounds [1 x i8*], [1 x i8*]* %3, i64 0, i64 0
%13 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %12)
br label %14
14: ; preds = %8, %2
ret i32 0
}