#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*/ package_set_device_clock_value(char *);
int /*<<< orphan*/ printf(char *);
int write_buffer(int, char *, char *);
int update_time(int tty) {
  char buffer[17];
  int res;
  printf("++ time:\n");
  package_set_device_clock_value(buffer);
  res = write_buffer(tty, buffer, buffer);
  if (res < 17) {
    printf("?? Can't update device time, package is too short\n");
    return res;
  }
  return 0;
}


x86 assembly (clang, -O0):
<update_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <package_set_device_clock_value@plt>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <write_buffer@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x11,-0x24(%rbp)
jge    1184 <update_time+0x54>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118b <update_time+0x5b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_time>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <package_set_device_clock_value@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1040 <write_buffer@plt>
mov    %eax,%ebx
xor    %eax,%eax
cmp    $0x10,%ebx
jg     1173 <update_time+0x43>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"++ time:\0A\00"
@.str.1 = [51 x i8] c"?? Can't update device time, package is too short\0A\00"
define i32 @update_time(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [17 x i8]
%5 = alloca i32
store i32 %0, i32* %3
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%8 = call i32 @package_set_device_clock_value(i8* %7)
%9 = load i32, i32* %3
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%12 = call i32 @write_buffer(i32 %9, i8* %10, i8* %11)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 17
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* %5
store i32 %17, i32* %2
br label %19
18: ; preds = %1
store i32 0, i32* %2
br label %19
19: ; preds = %18, %15
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@str = [9 x i8] c"++ time:\00"
@str.2 = [50 x i8] c"?? Can't update device time, package is too short\00"
define i32 @update_time(i32 %0) {
%2 = alloca [17 x i8]
%3 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%5 = call i32 @package_set_device_clock_value(i8* %3)
%6 = call i32 @write_buffer(i32 %0, i8* %3, i8* %3)
%7 = icmp slt i32 %6, 17
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.2, i64 0, i64 0))
br label %10
10: ; preds = %1, %8
%11 = phi i32 [ %6, %8 ], [ 0, %1 ]
ret i32 %11
}