#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 */
scalar_t__ netd_amIStartupMaster();
int netd_getMyID();
int /*<<< orphan*/ printf(char *, ...);
void check_master(char *prompt) {
  printf("%s\n", prompt);
  printf("myid = %d, ", netd_getMyID());
  if (netd_amIStartupMaster()) {
    printf("I am the startup master.\n");
  } else {
    printf("I am not the startup master.\n");
  }
}


x86 assembly (clang, -O0):
<check_master>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <netd_getMyID@plt>
mov    %eax,%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <netd_amIStartupMaster@plt>
cmp    $0x0,%rax
je     1189 <check_master+0x59>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1197 <check_master+0x67>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_master>:
push   %rax
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <netd_getMyID@plt>
lea    0xeac(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <netd_amIStartupMaster@plt>
test   %rax,%rax
lea    0xe9e(%rip),%rax
lea    0xeb4(%rip),%rdi
cmove  %rax,%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [12 x i8] c"myid = %d, \00"
@.str.2 = [26 x i8] c"I am the startup master.\0A\00"
@.str.3 = [30 x i8] c"I am not the startup master.\0A\00"
define void @check_master(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 (...) @netd_getMyID()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = call i64 (...) @netd_amIStartupMaster()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %13
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
ret void
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"myid = %d, \00"
@str = [29 x i8] c"I am not the startup master.\00"
@str.4 = [25 x i8] c"I am the startup master.\00"
define void @check_master(i8* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) %0)
%3 = tail call i32 (...) @netd_getMyID()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i64 (...) @netd_amIStartupMaster()
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.4, i64 0, i64 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
ret void
}