#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct sm_stat_res {
  int dummy;
};
struct TYPE_3__ {
  char *my_name;
  int my_proc;
  int /*<<< orphan*/ my_vers;
  int /*<<< orphan*/ my_prog;
};
struct TYPE_4__ {
  char *mon_name;
  TYPE_1__ my_id;
};
struct mon {
  TYPE_2__ mon_id;
};
typedef int /*<<< orphan*/ CLIENT;

/* Variables and functions */
int /*<<< orphan*/ SM_PROG;
int /*<<< orphan*/ SM_VERS;
int /*<<< orphan*/ *clnt_create(char *, int /*<<< orphan*/, int /*<<< orphan*/,
                                char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
struct sm_stat_res *sm_mon_1(struct mon *, int /*<<< orphan*/ *);
void *sm_simu_crash_1(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  CLIENT *cli;
  char dummy;
  void *out;
  struct mon mon;
  if (argc < 2) {
    fprintf(stderr, "usage: test <hostname> | crash\n");
    fprintf(stderr, "always talks to statd at localhost\n");
    exit(1);
  }
  printf("Creating client for localhost\n");
  cli = clnt_create("localhost", SM_PROG, SM_VERS, "udp");
  if (!cli) {
    printf("Failed to create client\n");
    exit(1);
  }
  mon.mon_id.mon_name = argv[1];
  mon.mon_id.my_id.my_name = argv[1];
  mon.mon_id.my_id.my_prog = SM_PROG;
  mon.mon_id.my_id.my_vers = SM_VERS;
  mon.mon_id.my_id.my_proc = 1;
  if (strcmp(argv[1], "crash")) {
    struct sm_stat_res *res;
    if (res = sm_mon_1(&mon, cli)) {
      printf("Success!\n");
    } else {
      printf("Fail\n");
    }
  } else {
    if (out = sm_simu_crash_1(&dummy, cli)) {
      printf("Success!\n");
    } else {
      printf("Fail\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c4 <main+0x54>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
mov    0x2e10(%rip),%rax
mov    (%rax),%edx
lea    0xe7a(%rip),%rdi
lea    0xe7d(%rip),%rcx
call   1080 <clnt_create@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121a <main+0xaa>
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     12ac <main+0x13c>
mov    -0x18(%rbp),%rsi
lea    -0x48(%rbp),%rdi
call   1030 <sm_mon_1@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
je     129b <main+0x12b>
lea    0xdff(%rip),%rdi
call   1040 <printf@plt>
jmp    12a7 <main+0x137>
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
jmp    12e9 <main+0x179>
mov    -0x18(%rbp),%rsi
lea    -0x19(%rbp),%rdi
call   1070 <sm_simu_crash_1@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     12d8 <main+0x168>
lea    0xdc2(%rip),%rdi
call   1040 <printf@plt>
jmp    12e4 <main+0x174>
lea    0xdbb(%rip),%rdi
call   1040 <printf@plt>
jmp    12e9 <main+0x179>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
jle    1241 <main+0xd1>
mov    %rsi,%r14
lea    0xec0(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e4e(%rip),%r15
mov    (%r15),%esi
mov    0x2e4c(%rip),%r12
mov    (%r12),%edx
lea    0xeb3(%rip),%rdi
lea    0xe8e(%rip),%rcx
call   1080 <clnt_create@plt>
test   %rax,%rax
je     126e <main+0xfe>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
mov    %rdi,0x8(%rsp)
mov    %rdi,0x10(%rsp)
mov    (%r15),%eax
mov    %eax,0x20(%rsp)
mov    (%r12),%eax
mov    %eax,0x1c(%rsp)
movl   $0x1,0x18(%rsp)
lea    0xe55(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     120c <main+0x9c>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <sm_mon_1@plt>
jmp    1219 <main+0xa9>
lea    0x7(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <sm_simu_crash_1@plt>
test   %rax,%rax
lea    0xe61(%rip),%rax
lea    0xe5f(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2d88(%rip),%rbx
mov    (%rbx),%edi
lea    0xdaf(%rip),%rsi
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdc1(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xdf7(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.mon = type { %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i8*, %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i8*, i32, i32, i32 }
%struct.sm_stat_res = type { i32 }
@stderr = global i32 0
@.str = [32 x i8] c"usage: test <hostname> | crash\0A\00"
@.str.1 = [36 x i8] c"always talks to statd at localhost\0A\00"
@.str.2 = [31 x i8] c"Creating client for localhost\0A\00"
@.str.3 = [10 x i8] c"localhost\00"
@SM_PROG = global i32 0
@SM_VERS = global i32 0
@.str.4 = [4 x i8] c"udp\00"
@.str.5 = [25 x i8] c"Failed to create client\0A\00"
@.str.6 = [6 x i8] c"crash\00"
@.str.7 = [10 x i8] c"Success!\0A\00"
@.str.8 = [6 x i8] c"Fail\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i8*
%9 = alloca %struct.mon
%10 = alloca %struct.sm_stat_res*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @SM_PROG
%22 = load i32, i32* @SM_VERS
%23 = call i32* @clnt_create(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp ne i32* %24, null
br i1 %25, label %29, label %26
26: ; preds = %19
%27 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %19
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = getelementptr inbounds %struct.mon, %struct.mon* %9, i32 0, i32 0
%34 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %33, i32 0, i32 0
store i8* %32, i8** %34
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = getelementptr inbounds %struct.mon, %struct.mon* %9, i32 0, i32 0
%39 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %38, i32 0, i32 1
%40 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %39, i32 0, i32 0
store i8* %37, i8** %40
%41 = load i32, i32* @SM_PROG
%42 = getelementptr inbounds %struct.mon, %struct.mon* %9, i32 0, i32 0
%43 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %42, i32 0, i32 1
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %43, i32 0, i32 3
store i32 %41, i32* %44
%45 = load i32, i32* @SM_VERS
%46 = getelementptr inbounds %struct.mon, %struct.mon* %9, i32 0, i32 0
%47 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %46, i32 0, i32 1
%48 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %47, i32 0, i32 2
store i32 %45, i32* %48
%49 = getelementptr inbounds %struct.mon, %struct.mon* %9, i32 0, i32 0
%50 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %49, i32 0, i32 1
%51 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %50, i32 0, i32 1
store i32 1, i32* %51
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %66
57: ; preds = %29
%58 = load i32*, i32** %6
%59 = call %struct.sm_stat_res* @sm_mon_1(%struct.mon* %9, i32* %58)
store %struct.sm_stat_res* %59, %struct.sm_stat_res** %10
%60 = icmp ne %struct.sm_stat_res* %59, null
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %65
63: ; preds = %57
%64 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
br label %75
66: ; preds = %29
%67 = load i32*, i32** %6
%68 = call i8* @sm_simu_crash_1(i8* %7, i32* %67)
store i8* %68, i8** %8
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %74
72: ; preds = %66
%73 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %74
74: ; preds = %72, %70
br label %75
75: ; preds = %74, %65
ret i32 0
}

LLVM IR (-O2):
%struct.mon = type { %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i8*, %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i8*, i32, i32, i32 }
%struct.sm_stat_res = type { i32 }
@stderr = global i32 0
@.str = [32 x i8] c"usage: test <hostname> | crash\0A\00"
@.str.1 = [36 x i8] c"always talks to statd at localhost\0A\00"
@.str.3 = [10 x i8] c"localhost\00"
@SM_PROG = global i32 0
@SM_VERS = global i32 0
@.str.4 = [4 x i8] c"udp\00"
@.str.6 = [6 x i8] c"crash\00"
@str = [30 x i8] c"Creating client for localhost\00"
@str.9 = [24 x i8] c"Failed to create client\00"
@str.12 = [5 x i8] c"Fail\00"
@str.13 = [9 x i8] c"Success!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca %struct.mon
%5 = bitcast %struct.mon* %4 to i8*
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* @SM_PROG
%16 = load i32, i32* @SM_VERS
%17 = tail call i32* @clnt_create(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %13
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = getelementptr inbounds %struct.mon, %struct.mon* %4, i64 0, i32 0, i32 0
store i8* %24, i8** %25
%26 = getelementptr inbounds %struct.mon, %struct.mon* %4, i64 0, i32 0, i32 1, i32 0
store i8* %24, i8** %26
%27 = load i32, i32* @SM_PROG
%28 = getelementptr inbounds %struct.mon, %struct.mon* %4, i64 0, i32 0, i32 1, i32 3
store i32 %27, i32* %28
%29 = load i32, i32* @SM_VERS
%30 = getelementptr inbounds %struct.mon, %struct.mon* %4, i64 0, i32 0, i32 1, i32 2
store i32 %29, i32* %30
%31 = getelementptr inbounds %struct.mon, %struct.mon* %4, i64 0, i32 0, i32 1, i32 1
store i32 1, i32* %31
%32 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %22
%35 = call %struct.sm_stat_res* @sm_mon_1(%struct.mon* %4, i32* %17)
%36 = icmp eq %struct.sm_stat_res* %35, null
%37 = select i1 %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.13, i64 0, i64 0)
br label %42
38: ; preds = %22
%39 = call i8* @sm_simu_crash_1(i8* %3, i32* %17)
%40 = icmp eq i8* %39, null
%41 = select i1 %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.13, i64 0, i64 0)
br label %42
42: ; preds = %38, %34
%43 = phi i8* [ %37, %34 ], [ %41, %38 ]
%44 = call i32 @puts(i8* dereferenceable(1) %43)
ret i32 0
}