#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 *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char path[128];
  sscanf(argv[0], "%s", path);
  ;
  if (strcmp("./cgi.cgi", path) == 0) {
    ;
    return 0;
  };
  execv(path, NULL);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x90(%rbp),%rdx
lea    0xea2(%rip),%rsi
call   1040 <sscanf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe92(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118c <main+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <main+0x73>
lea    -0x90(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <execv@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
mov    (%rsi),%rdi
lea    0xebe(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdx
call   1040 <sscanf@plt>
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116b <main+0x3b>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <execv@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"./cgi.cgi\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 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 0
%9 = load i8*, i8** %8
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%11 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%13 = call i64 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 0, i32* %3
br label %19
16: ; preds = %2
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%18 = call i32 @execv(i8* %17, i32* null)
store i32 0, i32* %3
br label %19
19: ; preds = %16, %15
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"./cgi.cgi\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %1
%6 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%7 = call i64 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call i32 @execv(i8* %4, i32* null)
br label %11
11: ; preds = %2, %9
ret i32 0
}