#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 int pid_t;

/* Variables and functions */
int /*<<< orphan*/ do_log(char *);
int /*<<< orphan*/ fork_script(int *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void do_id(pid_t *pid) {
  char m[30];
  if (!*pid) {
    fork_script(pid, "ider");
    sprintf(m,
            "Script: [%d] "
            "ider",
            *pid);
    do_log(m);
  } else {
    do_log("Failed: "
           "ider");
  }
}


x86 assembly (clang, -O0):
<do_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    117d <do_id+0x4d>
mov    -0x8(%rbp),%rdi
lea    0xec6(%rip),%rsi
call   1040 <fork_script@plt>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe96(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <do_log@plt>
jmp    1189 <do_id+0x59>
lea    0xe8e(%rip),%rdi
call   1030 <do_log@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_id>:
push   %rbx
sub    $0x20,%rsp
cmpl   $0x0,(%rdi)
je     114b <do_id+0x1b>
lea    0xed1(%rip),%rdi
add    $0x20,%rsp
pop    %rbx
jmp    1030 <do_log@plt>
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
call   1040 <fork_script@plt>
mov    (%rbx),%edx
lea    0xe9d(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <do_log@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"ider\00"
@.str.1 = [18 x i8] c"Script: [%d] ider\00"
@.str.2 = [13 x i8] c"Failed: ider\00"
define void @do_id(i32* %0) {
%2 = alloca i32*
%3 = alloca [30 x i8]
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = load i32, i32* %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %1
%8 = load i32*, i32** %2
%9 = call i32 @fork_script(i32* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%11 = load i32*, i32** %2
%12 = load i32, i32* %11
%13 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%15 = call i32 @do_log(i8* %14)
br label %18
16: ; preds = %1
%17 = call i32 @do_log(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %7
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"ider\00"
@.str.1 = [18 x i8] c"Script: [%d] ider\00"
@.str.2 = [13 x i8] c"Failed: ider\00"
define void @do_id(i32* %0) {
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* %0
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = tail call i32 @fork_script(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %0
%9 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 @do_log(i8* %3)
br label %13
11: ; preds = %1
%12 = tail call i32 @do_log(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
ret void
}