#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 /*<<< orphan*/ O_RDONLY;
scalar_t__ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int snprintf(char *, int, char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int get_machine_name(char *out, int out_len) {
  int fd;
  char buf[(sizeof("0123456789abcdef0123456789abcdef") - 1) + 1];
  if ((fd = open("/etc/machine-id", O_RDONLY)) == -1) {
    fprintf(stderr,
            "Error: "
            "Error opening \"/etc/machine-id\""
            ": %s"
            "\n",
            strerror(errno));
    ;
    goto _fail;
  };
  ;
  if (read(fd, buf, (sizeof("0123456789abcdef0123456789abcdef") - 1)) == -1) {
    fprintf(stderr,
            "Error: "
            "Error reading \"/etc/machine-id\""
            ": %s"
            "\n",
            strerror(errno));
    ;
    goto _fail_fd;
  };
  ;
  if (close(fd) != 0) {
    fprintf(stderr,
            "Error: "
            "Error closing \"/etc/machine-id\""
            ": %s"
            "\n",
            strerror(errno));
    ;
    goto _fail;
  };
  ;
  if (snprintf(out, out_len, "rkt-%.8s-%.4s-%.4s-%.4s-%.12s", buf, buf + 8,
               buf + 12, buf + 16, buf + 20) >= out_len) {
    fprintf(stderr, "Error: "
                    "Error constructing machine name"
                    "\n");
    ;
    goto _fail;
  };
  return 1;
_fail_fd:
  close(fd);
_fail:
  return 0;
}


x86 assembly (clang, -O0):
<get_machine_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
lea    0xe81(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    11c3 <get_machine_name+0x63>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12ce <get_machine_name+0x16e>
mov    -0x18(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x20,%edx
call   1050 <read@plt>
cmp    $0xffffffff,%eax
jne    1210 <get_machine_name+0xb0>
mov    0x2df4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rdx
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12c6 <get_machine_name+0x166>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
cmp    $0x0,%rax
je     1255 <get_machine_name+0xf5>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    %rax,%rdx
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12ce <get_machine_name+0x16e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x40(%rbp),%rcx
lea    -0x40(%rbp),%r8
add    $0x8,%r8
lea    -0x40(%rbp),%r9
add    $0xc,%r9
lea    -0x40(%rbp),%r10
add    $0x10,%r10
lea    -0x40(%rbp),%rax
add    $0x14,%rax
lea    0xe0d(%rip),%rdx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <snprintf@plt>
cmp    -0x14(%rbp),%eax
jl     12ba <get_machine_name+0x15a>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12ce <get_machine_name+0x16e>
movl   $0x1,-0x4(%rbp)
jmp    12d5 <get_machine_name+0x175>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_machine_name>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
mov    0x2e73(%rip),%rax
mov    (%rax),%esi
lea    0xe82(%rip),%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     11ce <get_machine_name+0x6e>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x20,%edx
call   1050 <read@plt>
cmp    $0xffffffff,%eax
je     11ff <get_machine_name+0x9f>
mov    %ebx,%edi
call   1040 <close@plt>
test   %rax,%rax
je     1236 <get_machine_name+0xd6>
mov    0x2e23(%rip),%rax
mov    (%rax),%ebx
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe9c(%rip),%rsi
jmp    11ec <get_machine_name+0x8c>
mov    0x2e03(%rip),%rax
mov    (%rax),%ebx
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe24(%rip),%rsi
xor    %ebp,%ebp
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1288 <get_machine_name+0x128>
mov    0x2dd2(%rip),%rax
mov    (%rax),%r14d
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe1e(%rip),%rsi
xor    %ebp,%ebp
mov    %r14d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebx,%edi
call   1040 <close@plt>
jmp    1288 <get_machine_name+0x128>
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
lea    0x10(%rsp),%rax
lea    0x14(%rsp),%rbx
lea    0xe43(%rip),%rdx
mov    %rsp,%rcx
mov    %rbp,%rdi
mov    %r14d,%esi
push   %rbx
push   %rax
call   1030 <snprintf@plt>
add    $0x10,%rsp
mov    $0x1,%ebp
cmp    %r14d,%eax
jl     1288 <get_machine_name+0x128>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebp,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"/etc/machine-id\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.1 = [44 x i8] c"Error: Error opening \22/etc/machine-id\22: %s\0A\00"
@errno = global i32 0
@.str.2 = [44 x i8] c"Error: Error reading \22/etc/machine-id\22: %s\0A\00"
@.str.3 = [44 x i8] c"Error: Error closing \22/etc/machine-id\22: %s\0A\00"
@.str.4 = [30 x i8] c"rkt-%.8s-%.4s-%.4s-%.4s-%.12s\00"
@.str.5 = [40 x i8] c"Error: Error constructing machine name\0A\00"
define i32 @get_machine_name(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [33 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i32, i32* @O_RDONLY
%9 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 %9, i32* %6
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %57
16: ; preds = %2
%17 = load i32, i32* %6
%18 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%19 = call i32 @read(i32 %17, i8* %18, i32 32)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %54
26: ; preds = %16
%27 = load i32, i32* %6
%28 = call i64 @close(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %57
35: ; preds = %26
%36 = load i8*, i8** %4
%37 = load i32, i32* %5
%38 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%39 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%40 = getelementptr inbounds i8, i8* %39, i64 8
%41 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%42 = getelementptr inbounds i8, i8* %41, i64 12
%43 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%44 = getelementptr inbounds i8, i8* %43, i64 16
%45 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%46 = getelementptr inbounds i8, i8* %45, i64 20
%47 = call i32 @snprintf(i8* %36, i32 %37, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %38, i8* %40, i8* %42, i8* %44, i8* %46)
%48 = load i32, i32* %5
%49 = icmp sge i32 %47, %48
br i1 %49, label %50, label %53
50: ; preds = %35
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %57
53: ; preds = %35
store i32 1, i32* %3
br label %58
54: ; preds = %21
%55 = load i32, i32* %6
%56 = call i64 @close(i32 %55)
br label %57
57: ; preds = %54, %50, %30, %11
store i32 0, i32* %3
br label %58
58: ; preds = %57, %53
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@.str = [16 x i8] c"/etc/machine-id\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.1 = [44 x i8] c"Error: Error opening \22/etc/machine-id\22: %s\0A\00"
@errno = global i32 0
@.str.2 = [44 x i8] c"Error: Error reading \22/etc/machine-id\22: %s\0A\00"
@.str.3 = [44 x i8] c"Error: Error closing \22/etc/machine-id\22: %s\0A\00"
@.str.4 = [30 x i8] c"rkt-%.8s-%.4s-%.4s-%.4s-%.12s\00"
@.str.5 = [40 x i8] c"Error: Error constructing machine name\0A\00"
define i32 @get_machine_name(i8* %0, i32 %1) {
%3 = alloca [33 x i8]
%4 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = tail call i8* @strerror(i32 %10)
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %40
13: ; preds = %2
%14 = call i32 @read(i32 %6, i8* %4, i32 32)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = tail call i8* @strerror(i32 %18)
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = tail call i64 @close(i32 %6)
br label %40
22: ; preds = %13
%23 = tail call i64 @close(i32 %6)
%24 = icmp eq i64 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = tail call i8* @strerror(i32 %27)
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %40
30: ; preds = %22
%31 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 8
%32 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 12
%33 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 16
%34 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 20
%35 = call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* %31, i8* %32, i8* %33, i8* %34)
%36 = icmp slt i32 %35, %1
br i1 %36, label %40, label %37
37: ; preds = %30
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %8, %25, %37, %16, %30
%41 = phi i32 [ 1, %30 ], [ 0, %16 ], [ 0, %37 ], [ 0, %25 ], [ 0, %8 ]
ret i32 %41
}