#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*/ execlp(char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ th_main(char *);
int /*<<< orphan*/ vfork();
int main(int argc, char **argv) {
  if (argc != 1) {
    th_main("aaa");
    return 0;
  }
  if (!vfork())
    execlp(argv[0], argv[0], "", NULL);
  th_main("bbb");
  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   $0x1,-0x8(%rbp)
je     1168 <main+0x38>
lea    0xea9(%rip),%rdi
call   1030 <th_main@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a7 <main+0x77>
call   1040 <vfork@plt>
cmp    $0x0,%eax
jne    1194 <main+0x64>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe78(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <execlp@plt>
lea    0xe69(%rip),%rdi
call   1030 <th_main@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1167 <main+0x37>
mov    %rsi,%rbx
call   1040 <vfork@plt>
lea    0xebc(%rip),%r14
test   %eax,%eax
jne    1162 <main+0x32>
mov    (%rbx),%rdi
lea    0xead(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    %rdi,%rsi
call   1050 <execlp@plt>
mov    %r14,%rdi
jmp    116e <main+0x3e>
lea    0xe92(%rip),%rdi
call   1030 <th_main@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"aaa\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c"bbb\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, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @th_main(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %23
10: ; preds = %2
%11 = call i32 @vfork()
%12 = icmp ne i32 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %10
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @execlp(i8* %16, i8* %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32* null)
br label %21
21: ; preds = %13, %10
%22 = call i32 @th_main(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %23
23: ; preds = %21, %8
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [4 x i8] c"aaa\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c"bbb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = call i32 @vfork()
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i8*, i8** %1
%9 = call i32 @execlp(i8* %8, i8* %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32* null)
br label %10
10: ; preds = %4, %7, %2
%11 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %4 ]
%12 = call i32 @th_main(i8* %11)
ret i32 0
}