#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 */
char *get_current_time();
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int);
int set_output(int fd, int c) {
  char obuf[10];
  char bbuf[200];
  char *p;
  sprintf(obuf, "L%01X%01X", c, c);
  sprintf(bbuf, "output command = %5s (%d)", obuf, c);
  printf("%s : %s\n", get_current_time(), bbuf);
  obuf[3] = 10;
  obuf[4] = 0;
  obuf[5] = 0;
  p = &obuf[0];
  while (*p != 0) {
    write(fd, p, 1);
    usleep(100);
    p++;
  }
  return (0);
}


x86 assembly (clang, -O0):
<set_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x12(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x12(%rbp),%rdx
mov    -0x8(%rbp),%ecx
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    $0x0,%al
call   1050 <get_current_time@plt>
mov    %rax,%rsi
lea    -0xe0(%rbp),%rdx
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
movb   $0xa,-0xf(%rbp)
movb   $0x0,-0xe(%rbp)
movb   $0x0,-0xd(%rbp)
lea    -0x12(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1211 <set_output+0xc1>
mov    -0x4(%rbp),%edi
mov    -0xe8(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x64,%edi
call   1070 <usleep@plt>
mov    -0xe8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xe8(%rbp)
jmp    11c9 <set_output+0x79>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_output>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
lea    0xe97(%rip),%rsi
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xe85(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1060 <sprintf@plt>
xor    %eax,%eax
call   1050 <get_current_time@plt>
lea    0xe7c(%rip),%rdi
mov    %rax,%rsi
mov    %r15,%rdx
call   1040 <printf@plt>
movw   $0xa,0x9(%rsp)
movb   $0x0,0xb(%rsp)
cmpb   $0x0,0x6(%rsp)
je     11f3 <set_output+0xa3>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x64,%edi
call   1070 <usleep@plt>
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    11d0 <set_output+0x80>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"L%01X%01X\00"
@.str.1 = [26 x i8] c"output command = %5s (%d)\00"
@.str.2 = [9 x i8] c"%s : %s\0A\00"
define i32 @set_output(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i8]
%6 = alloca [200 x i8]
%7 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%9 = load i32, i32* %4
%10 = load i32, i32* %4
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%14 = load i32, i32* %4
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %13, i32 %14)
%16 = call i8* (...) @get_current_time()
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* %17)
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 3
store i8 10, i8* %19
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 4
store i8 0, i8* %20
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 5
store i8 0, i8* %21
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
store i8* %22, i8** %7
br label %23
23: ; preds = %28, %2
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %23
%29 = load i32, i32* %3
%30 = load i8*, i8** %7
%31 = call i32 @write(i32 %29, i8* %30, i32 1)
%32 = call i32 @usleep(i32 100)
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %7
br label %23
35: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"L%01X%01X\00"
@.str.1 = [26 x i8] c"output command = %5s (%d)\00"
@.str.2 = [9 x i8] c"%s : %s\0A\00"
define i32 @set_output(i32 %0, i32 %1) {
%3 = alloca [10 x i8]
%4 = alloca [200 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %1)
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %1)
%9 = call i8* (...) @get_current_time()
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %6)
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
store i8 10, i8* %11
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 4
store i8 0, i8* %12
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 5
store i8 0, i8* %13
%14 = load i8, i8* %5
%15 = icmp eq i8 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %2, %16
%17 = phi i8* [ %20, %16 ], [ %5, %2 ]
%18 = call i32 @write(i32 %0, i8* %17, i32 1)
%19 = call i32 @usleep(i32 100)
%20 = getelementptr inbounds i8, i8* %17, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %16
23: ; preds = %16, %2
ret i32 0
}