#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 */
struct sem_test {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ _SC_NPROCESSORS_ONLN;
struct sem_test *create_sem_test(int /*<<< orphan*/);
int /*<<< orphan*/ do_options(int, char **, struct sem_test *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_summary(struct sem_test *);
int /*<<< orphan*/ run_test(struct sem_test *);
int /*<<< orphan*/ sysconf(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct sem_test *st = create_sem_test(sysconf(_SC_NPROCESSORS_ONLN));
  if (!st) {
    perror("Could not create st\n");
    return -1;
  }
  do_options(argc, argv, st);
  run_test(st);
  print_summary(st);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1060 <sysconf@plt>
mov    %eax,%edi
call   1030 <create_sem_test@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b2 <main+0x52>
lea    0xe5f(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11db <main+0x7b>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1080 <do_options@plt>
mov    -0x18(%rbp),%rdi
call   1040 <run_test@plt>
mov    -0x18(%rbp),%rdi
call   1070 <print_summary@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1060 <sysconf@plt>
mov    %eax,%edi
call   1030 <create_sem_test@plt>
test   %rax,%rax
je     11aa <main+0x4a>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1080 <do_options@plt>
mov    %rbx,%rdi
call   1040 <run_test@plt>
mov    %rbx,%rdi
call   1070 <print_summary@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe4f(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
jmp    11a5 <main+0x45>

LLVM IR (-O0):
%struct.sem_test = type { i32 }
@_SC_NPROCESSORS_ONLN = global i32 0
@.str = [21 x i8] c"Could not create st\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sem_test*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @_SC_NPROCESSORS_ONLN
%8 = call i32 @sysconf(i32 %7)
%9 = call %struct.sem_test* @create_sem_test(i32 %8)
store %struct.sem_test* %9, %struct.sem_test** %6
%10 = load %struct.sem_test*, %struct.sem_test** %6
%11 = icmp ne %struct.sem_test* %10, null
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %23
14: ; preds = %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = load %struct.sem_test*, %struct.sem_test** %6
%18 = call i32 @do_options(i32 %15, i8** %16, %struct.sem_test* %17)
%19 = load %struct.sem_test*, %struct.sem_test** %6
%20 = call i32 @run_test(%struct.sem_test* %19)
%21 = load %struct.sem_test*, %struct.sem_test** %6
%22 = call i32 @print_summary(%struct.sem_test* %21)
store i32 0, i32* %3
br label %23
23: ; preds = %14, %12
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
%struct.sem_test = type { i32 }
@_SC_NPROCESSORS_ONLN = global i32 0
@.str = [21 x i8] c"Could not create st\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @_SC_NPROCESSORS_ONLN
%4 = tail call i32 @sysconf(i32 %3)
%5 = tail call %struct.sem_test* @create_sem_test(i32 %4)
%6 = icmp eq %struct.sem_test* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %13
9: ; preds = %2
%10 = tail call i32 @do_options(i32 %0, i8** %1, %struct.sem_test* %5)
%11 = tail call i32 @run_test(%struct.sem_test* %5)
%12 = tail call i32 @print_summary(%struct.sem_test* %5)
br label %13
13: ; preds = %9, %7
%14 = phi i32 [ 0, %9 ], [ -1, %7 ]
ret i32 %14
}