#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 utsname {
  int dummy;
};

/* Variables and functions */
int expect_gez(int /*<<< orphan*/, int /*<<< orphan*/);
int expect_zng(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ getdomainname_test(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ testbreak();
int /*<<< orphan*/ uname_test(struct utsname *);
int BasicName(void) {
  int passed;
  int block = 0;
  struct utsname ut;
  char name[8192] = {0};
  testbreak();
  passed = expect_gez(0, uname_test(&ut));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  testbreak();
  passed = expect_zng(0, getdomainname_test(name, 8192));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  testbreak();
  return block;
}


x86 assembly (clang, -O0):
<BasicName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2010,%rsp
movl   $0x0,-0x8(%rbp)
lea    -0x2010(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1060 <memset@plt>
mov    $0x0,%al
call   1090 <testbreak@plt>
lea    -0x10(%rbp),%rdi
call   1040 <uname_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10a0 <expect_gez@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11e7 <BasicName+0x67>
lea    0xe2e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    $0x0,%al
call   1090 <testbreak@plt>
lea    -0x2010(%rbp),%rdi
mov    $0x2000,%esi
call   1030 <getdomainname_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1070 <expect_zng@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1231 <BasicName+0xb1>
lea    0xde4(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    $0x0,%al
call   1090 <testbreak@plt>
mov    -0x8(%rbp),%eax
add    $0x2010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BasicName>:
push   %rbx
sub    $0x2010,%rsp
lea    0x10(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x2000,%edx
xor    %esi,%esi
call   1060 <memset@plt>
xor    %eax,%eax
call   1090 <testbreak@plt>
lea    0x8(%rsp),%rdi
call   1050 <uname_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10a0 <expect_gez@plt>
test   %eax,%eax
je     11d1 <BasicName+0x51>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <fflush@plt>
mov    $0xffffffff,%ebx
xor    %eax,%eax
call   1090 <testbreak@plt>
lea    0x10(%rsp),%rdi
mov    $0x2000,%esi
call   1030 <getdomainname_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1070 <expect_zng@plt>
test   %eax,%eax
je     120c <BasicName+0x8c>
lea    0xe05(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <fflush@plt>
mov    $0xffffffff,%ebx
xor    %eax,%eax
call   1090 <testbreak@plt>
mov    %ebx,%eax
add    $0x2010,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.utsname = type { i32 }
@.str = [54 x i8] c"\09Failed Phase 2: This call did something unexpected.\0A\00"
define i32 @BasicName() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.utsname
%4 = alloca [8192 x i8]
store i32 0, i32* %2
%5 = bitcast [8192 x i8]* %4 to i8*
%6 = call i32 (...) @testbreak()
%7 = call i32 @uname_test(%struct.utsname* %3)
%8 = call i32 @expect_gez(i32 0, i32 %7)
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @fflush(i32* null)
store i32 -1, i32* %2
br label %14
14: ; preds = %11, %0
%15 = call i32 (...) @testbreak()
%16 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%17 = call i32 @getdomainname_test(i8* %16, i32 8192)
%18 = call i32 @expect_zng(i32 0, i32 %17)
store i32 %18, i32* %1
%19 = load i32, i32* %1
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @fflush(i32* null)
store i32 -1, i32* %2
br label %24
24: ; preds = %21, %14
%25 = call i32 (...) @testbreak()
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
@str.1 = [53 x i8] c"\09Failed Phase 2: This call did something unexpected.\00"
define i32 @BasicName() {
%1 = alloca %struct.utsname
%2 = alloca [8192 x i8]
%3 = bitcast %struct.utsname* %1 to i8*
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @testbreak()
%6 = call i32 @uname_test(%struct.utsname* %1)
%7 = call i32 @expect_gez(i32 0, i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.1, i64 0, i64 0))
%11 = call i32 @fflush(i32* null)
br label %12
12: ; preds = %9, %0
%13 = phi i32 [ -1, %9 ], [ 0, %0 ]
%14 = call i32 (...) @testbreak()
%15 = call i32 @getdomainname_test(i8* %4, i32 8192)
%16 = call i32 @expect_zng(i32 0, i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.1, i64 0, i64 0))
%20 = call i32 @fflush(i32* null)
br label %21
21: ; preds = %18, %12
%22 = phi i32 [ -1, %18 ], [ %13, %12 ]
%23 = call i32 (...) @testbreak()
ret i32 %22
}