#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 WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ printf(char *, ...);
int system(char const *);
void doSystem(const char cmd[]) {
  printf("exit1: Executing cmd '%s'\n", cmd);
  int exitStatus = system(cmd);
  printf("exit1: raw exitStatus = %d\n", exitStatus);
  if (WIFEXITED(exitStatus)) {
    printf("exit1: WEXITSTATUS(exitStatus) = %d\n", WEXITSTATUS(exitStatus));
  }
}


x86 assembly (clang, -O0):
<doSystem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1060 <WIFEXITED@plt>
cmp    $0x0,%rax
je     11a5 <doSystem+0x65>
mov    -0xc(%rbp),%edi
call   1050 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doSystem>:
push   %rbx
mov    %rdi,%rbx
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %eax,%ebx
lea    0xeb5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1060 <WIFEXITED@plt>
test   %rax,%rax
je     1193 <doSystem+0x53>
mov    %ebx,%edi
call   1050 <WEXITSTATUS@plt>
lea    0xeae(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"exit1: Executing cmd '%s'\0A\00"
@.str.1 = [28 x i8] c"exit1: raw exitStatus = %d\0A\00"
@.str.2 = [37 x i8] c"exit1: WEXITSTATUS(exitStatus) = %d\0A\00"
define void @doSystem(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i8*, i8** %2
%7 = call i32 @system(i8* %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %3
%11 = call i64 @WIFEXITED(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32, i32* %3
%15 = call i32 @WEXITSTATUS(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %13, %1
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"exit1: Executing cmd '%s'\0A\00"
@.str.1 = [28 x i8] c"exit1: raw exitStatus = %d\0A\00"
@.str.2 = [37 x i8] c"exit1: WEXITSTATUS(exitStatus) = %d\0A\00"
define void @doSystem(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32 @system(i8* %0)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i64 @WIFEXITED(i32 %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = tail call i32 @WEXITSTATUS(i32 %3)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %1
ret void
}