#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ abort();
scalar_t__ fork();
int getpid();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
int /*<<< orphan*/ wait(int *);
int normal_fun() {
  do {
    printf("%s:%d ",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/"
           "clang/posix/wait.c",
           33);
    printf("fork() ...");
    printf("\n");
  } while (0);
  pid_t pid = fork();
  if (0 == pid) {
    do {
      printf("%s:%d ",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/"
             "clang/posix/wait.c",
             37);
      printf("in child, pid = [%d], will abort...", getpid());
      printf("\n");
    } while (0);
    raise(SIGINT);
    abort();
  } else if (pid > 0) {
    do {
      printf("%s:%d ",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/"
             "clang/posix/wait.c",
             42);
      printf("in parent, pid = [%d]...", getpid());
      printf("\n");
    } while (0);
    int st = 0;
    do {
      printf("%s:%d ",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/"
             "clang/posix/wait.c",
             44);
      printf("wait for child, pid = [%d]", getpid());
      printf("\n");
    } while (0);
    wait(&st);
    do {
      printf("%s:%d ",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/"
             "clang/posix/wait.c",
             46);
      printf("child returns : [%d]", st);
      printf("\n");
    } while (0);
  } else {
    do {
      printf("%s:%d ",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/"
             "clang/posix/wait.c",
             49);
      printf("error occur...");
      printf("\n");
    } while (0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<normal_fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
lea    0xe91(%rip),%rsi
mov    $0x21,%edx
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xf0f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
jne    120e <normal_fun+0xae>
jmp    11ba <normal_fun+0x5a>
lea    0xe3f(%rip),%rdi
lea    0xe3f(%rip),%rsi
mov    $0x25,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
mov    $0x0,%al
call   1040 <abort@plt>
cmpq   $0x0,-0x8(%rbp)
jle    12ea <normal_fun+0x18a>
jmp    121e <normal_fun+0xbe>
lea    0xddb(%rip),%rdi
lea    0xddb(%rip),%rsi
mov    $0x2a,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0xc(%rbp)
lea    0xd95(%rip),%rdi
lea    0xd95(%rip),%rsi
mov    $0x2c,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xc(%rbp),%rdi
call   1070 <wait@plt>
lea    0xd4d(%rip),%rdi
lea    0xd4d(%rip),%rsi
mov    $0x2e,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    132a <normal_fun+0x1ca>
jmp    12ef <normal_fun+0x18f>
lea    0xd0a(%rip),%rdi
lea    0xd0a(%rip),%rsi
mov    $0x31,%edx
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    132a <normal_fun+0x1ca>
jmp    132f <normal_fun+0x1cf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normal_fun>:
push   %r14
push   %rbx
push   %rax
lea    0xe85(%rip),%rdi
lea    0xe85(%rip),%rsi
mov    $0x21,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xf06(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %rax,%rax
je     12a4 <normal_fun+0x134>
jle    1268 <normal_fun+0xf8>
lea    0xe3d(%rip),%rbx
lea    0xe3d(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2a,%edx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xee0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
movl   $0x0,0x4(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2c,%edx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xebe(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0x4(%rsp),%rdi
call   1080 <wait@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2e,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1290 <normal_fun+0x120>
lea    0xd91(%rip),%rdi
lea    0xd91(%rip),%rsi
mov    $0x31,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd55(%rip),%rdi
lea    0xd55(%rip),%rsi
mov    $0x25,%edx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xdda(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
xor    %eax,%eax
call   1050 <abort@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%s:%d \00"
@.str.1 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/clang/posix/wait.c\00"
@.str.2 = [11 x i8] c"fork() ...\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [36 x i8] c"in child, pid = [%d], will abort...\00"
@SIGINT = global i32 0
@.str.5 = [25 x i8] c"in parent, pid = [%d]...\00"
@.str.6 = [27 x i8] c"wait for child, pid = [%d]\00"
@.str.7 = [21 x i8] c"child returns : [%d]\00"
@.str.8 = [15 x i8] c"error occur...\00"
define i32 @normal_fun() {
%1 = alloca i64
%2 = alloca i32
br label %3
3: ; preds = %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 33)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %3
%8 = call i64 (...) @fork()
store i64 %8, i64* %1
%9 = load i64, i64* %1
%10 = icmp eq i64 0, %9
br i1 %10, label %11, label %21
11: ; preds = %7
br label %12
12: ; preds = %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 37)
%14 = call i32 (...) @getpid()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %12
%18 = load i32, i32* @SIGINT
%19 = call i32 @raise(i32 %18)
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %7
%22 = load i64, i64* %1
%23 = icmp sgt i64 %22, 0
br i1 %23, label %24, label %44
24: ; preds = %21
br label %25
25: ; preds = %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 42)
%27 = call i32 (...) @getpid()
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %25
store i32 0, i32* %2
br label %31
31: ; preds = %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 44)
%33 = call i32 (...) @getpid()
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %31
%37 = call i32 @wait(i32* %2)
br label %38
38: ; preds = %36
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 46)
%40 = load i32, i32* %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %38
br label %50
44: ; preds = %21
br label %45
45: ; preds = %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 49)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %45
br label %50
50: ; preds = %49, %43
br label %51
51: ; preds = %50
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s:%d \00"
@.str.1 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fengbohello/practice/refs/heads/master/clang/posix/wait.c\00"
@.str.2 = [11 x i8] c"fork() ...\00"
@.str.4 = [36 x i8] c"in child, pid = [%d], will abort...\00"
@SIGINT = global i32 0
@.str.5 = [25 x i8] c"in parent, pid = [%d]...\00"
@.str.6 = [27 x i8] c"wait for child, pid = [%d]\00"
@.str.7 = [21 x i8] c"child returns : [%d]\00"
@.str.8 = [15 x i8] c"error occur...\00"
define i32 @normal_fun() {
%1 = alloca i32
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 33)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @putchar(i32 10)
%5 = tail call i64 (...) @fork()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 37)
%9 = tail call i32 (...) @getpid()
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = tail call i32 @putchar(i32 10)
%12 = load i32, i32* @SIGINT
%13 = tail call i32 @raise(i32 %12)
%14 = tail call i32 (...) @abort()
unreachable
15: ; preds = %0
%16 = icmp sgt i64 %5, 0
br i1 %16, label %17, label %32
17: ; preds = %15
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 42)
%19 = tail call i32 (...) @getpid()
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = tail call i32 @putchar(i32 10)
%22 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 44)
%24 = tail call i32 (...) @getpid()
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %24)
%26 = tail call i32 @putchar(i32 10)
%27 = call i32 @wait(i32* %1)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 46)
%29 = load i32, i32* %1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %29)
%31 = call i32 @putchar(i32 10)
br label %36
32: ; preds = %15
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 49)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%35 = tail call i32 @putchar(i32 10)
br label %36
36: ; preds = %17, %32
ret i32 0
}