#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 utmpx {
  short ut_type;
  int /*<<< orphan*/ ut_tv;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *pututxline(struct utmpx *);
int boot(short type) {
  struct utmpx utx = {.ut_type = type};
  (void)gettimeofday(&utx.ut_tv, NULL);
  if (pututxline(&utx) == NULL) {
    perror("pututxline");
    return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<boot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x6(%rbp)
mov    -0x6(%rbp),%ax
mov    %ax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x4,%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x10(%rbp),%rdi
call   1040 <pututxline@plt>
cmp    $0x0,%rax
jne    118a <boot+0x5a>
lea    0xe87(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1191 <boot+0x61>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boot>:
push   %rbx
sub    $0x10,%rsp
mov    %di,0x8(%rsp)
lea    0xc(%rsp),%rdi
movl   $0x0,0xc(%rsp)
xor    %ebx,%ebx
xor    %esi,%esi
call   1030 <gettimeofday@plt>
lea    0x8(%rsp),%rdi
call   1040 <pututxline@plt>
test   %rax,%rax
je     1167 <boot+0x37>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe92(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%ebx
jmp    115f <boot+0x2f>

LLVM IR (-O0):
%struct.utmpx = type { i16, i32 }
@.str = [11 x i8] c"pututxline\00"
define i32 @boot(i16 signext %0) {
%2 = alloca i32
%3 = alloca i16
%4 = alloca %struct.utmpx
store i16 %0, i16* %3
%5 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %4, i32 0, i32 0
%6 = load i16, i16* %3
store i16 %6, i16* %5
%7 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %4, i32 0, i32 1
store i32 0, i32* %7
%8 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %4, i32 0, i32 1
%9 = call i32 @gettimeofday(i32* %8, i32* null)
%10 = call i32* @pututxline(%struct.utmpx* %4)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %15
14: ; preds = %1
store i32 0, i32* %2
br label %15
15: ; preds = %14, %12
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
%struct.utmpx = type { i16, i32 }
@.str = [11 x i8] c"pututxline\00"
define i32 @boot(i16 signext %0) {
%2 = alloca %struct.utmpx
%3 = bitcast %struct.utmpx* %2 to i8*
%4 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %2, i64 0, i32 0
store i16 %0, i16* %4
%5 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %2, i64 0, i32 1
store i32 0, i32* %5
%6 = call i32 @gettimeofday(i32* %5, i32* null)
%7 = call i32* @pututxline(%struct.utmpx* %2)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %1, %9
%12 = phi i32 [ 1, %9 ], [ 0, %1 ]
ret i32 %12
}