#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ usleep(int);
void display(char *msg) {
  FILE *fp;
  int len = strlen(msg);
  char disp[100];
  char blank[17];
  int i;
  fp = fopen("/dev/lcd_ascii", "wt");
  if (fp == NULL) {
    fprintf(stderr, "Failed to open device driver!\n");
    exit(1);
  }
  for (i = 0; i < 17; i++) {
    blank[i] = ' ';
  }
  for (i = 0; i < 17 - 2; i++)
    disp[i] = ' ';
  for (i = 0; i < len; i++)
    disp[i + (17 - 2)] = msg[i];
  for (i = 0; i < 17 - 2; i++)
    disp[i + (17 - 2) + len] = ' ';
  for (i = 0; i < len + (17 - 2); i++) {
    fwrite(disp + i, 1, 17 + 1, fp);
    fflush(fp);
    usleep(500 * 1000);
    fwrite(blank, 1, 17 + 1, fp);
    fflush(fp);
    usleep(160 * 1000);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
lea    0xe5e(%rip),%rdi
lea    0xe66(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11dc <display+0x5c>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x11,-0xa4(%rbp)
jge    1216 <display+0x96>
movslq -0xa4(%rbp),%rax
movb   $0x20,-0xa0(%rbp,%rax,1)
20
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    11e6 <display+0x66>
movl   $0x0,-0xa4(%rbp)
cmpl   $0xf,-0xa4(%rbp)
jge    124d <display+0xcd>
movslq -0xa4(%rbp),%rax
movb   $0x20,-0x80(%rbp,%rax,1)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1220 <display+0xa0>
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1297 <display+0x117>
mov    -0x8(%rbp),%rax
movslq -0xa4(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0xa4(%rbp),%eax
add    $0xf,%eax
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1257 <display+0xd7>
movl   $0x0,-0xa4(%rbp)
cmpl   $0xf,-0xa4(%rbp)
jge    12d5 <display+0x155>
mov    -0xa4(%rbp),%eax
add    $0xf,%eax
add    -0x14(%rbp),%eax
cltq
movb   $0x20,-0x80(%rbp,%rax,1)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    12a1 <display+0x121>
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0xf,%ecx
cmp    %ecx,%eax
jge    1368 <display+0x1e8>
lea    -0x80(%rbp),%rdi
movslq -0xa4(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x12,%edx
call   1090 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1060 <fflush@plt>
mov    $0x7a120,%edi
call   10a0 <usleep@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x12,%edx
call   1090 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1060 <fflush@plt>
mov    $0x27100,%edi
call   10a0 <usleep@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    12df <display+0x15f>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%r14d
lea    0xe60(%rip),%rdi
lea    0xe68(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12ce <display+0x13e>
mov    %rax,%r15
movaps 0xe31(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x20,0x10(%rsp)
movabs $0x2020202020202020,%r12
20 20 20
mov    %r12,0x20(%rsp)
mov    %r12,0x27(%rsp)
test   %r14d,%r14d
jle    1201 <display+0x71>
lea    0x2f(%rsp),%rdi
mov    %r14d,%edx
mov    %rbx,%rsi
call   1060 <memcpy@plt>
lea    0xf(%r14),%eax
cltq
mov    %r12,0x20(%rsp,%rax,1)
lea    0x17(%r14),%eax
cltq
movl   $0x20202020,0x20(%rsp,%rax,1)
20
lea    0x1b(%r14),%eax
cltq
movw   $0x2020,0x20(%rsp,%rax,1)
lea    0x1d(%r14),%eax
cltq
movb   $0x20,0x20(%rsp,%rax,1)
cmp    $0xfffffff2,%r14d
jl     12b8 <display+0x128>
add    $0xe,%r14d
xor    %r12d,%r12d
test   %r14d,%r14d
cmovg  %r14d,%r12d
add    $0x1,%r12d
lea    0x20(%rsp),%rbx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x12,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    %r15,%rdi
call   1070 <fflush@plt>
mov    $0x7a120,%edi
call   10b0 <usleep@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x12,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    %r15,%rdi
call   1070 <fflush@plt>
mov    $0x27100,%edi
call   10b0 <usleep@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r12
jne    1260 <display+0xd0>
mov    %r15,%rdi
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
lea    0xd44(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"/dev/lcd_ascii\00"
@.str.1 = [3 x i8] c"wt\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"Failed to open device driver!\0A\00"
define void @display(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca [17 x i8]
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %4
%10 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %1
store i32 0, i32* %7
br label %18
18: ; preds = %25, %17
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 17
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 %23
store i8 32, i8* %24
br label %25
25: ; preds = %21
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %18
28: ; preds = %18
store i32 0, i32* %7
br label %29
29: ; preds = %36, %28
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 15
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %34
store i8 32, i8* %35
br label %36
36: ; preds = %32
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %29
39: ; preds = %29
store i32 0, i32* %7
br label %40
40: ; preds = %54, %39
%41 = load i32, i32* %7
%42 = load i32, i32* %4
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %57
44: ; preds = %40
%45 = load i8*, i8** %2
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 15
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %52
store i8 %49, i8* %53
br label %54
54: ; preds = %44
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %40
57: ; preds = %40
store i32 0, i32* %7
br label %58
58: ; preds = %68, %57
%59 = load i32, i32* %7
%60 = icmp slt i32 %59, 15
br i1 %60, label %61, label %71
61: ; preds = %58
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 15
%64 = load i32, i32* %4
%65 = add nsw i32 %63, %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %66
store i8 32, i8* %67
br label %68
68: ; preds = %61
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %58
71: ; preds = %58
store i32 0, i32* %7
br label %72
72: ; preds = %93, %71
%73 = load i32, i32* %7
%74 = load i32, i32* %4
%75 = add nsw i32 %74, 15
%76 = icmp slt i32 %73, %75
br i1 %76, label %77, label %96
77: ; preds = %72
%78 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%79 = load i32, i32* %7
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = load i32*, i32** %3
%83 = call i32 @fwrite(i8* %81, i32 1, i32 18, i32* %82)
%84 = load i32*, i32** %3
%85 = call i32 @fflush(i32* %84)
%86 = call i32 @usleep(i32 500000)
%87 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%88 = load i32*, i32** %3
%89 = call i32 @fwrite(i8* %87, i32 1, i32 18, i32* %88)
%90 = load i32*, i32** %3
%91 = call i32 @fflush(i32* %90)
%92 = call i32 @usleep(i32 160000)
br label %93
93: ; preds = %77
%94 = load i32, i32* %7
%95 = add nsw i32 %94, 1
store i32 %95, i32* %7
br label %72
96: ; preds = %72
%97 = load i32*, i32** %3
%98 = call i32 @fclose(i32* %97)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"/dev/lcd_ascii\00"
@.str.1 = [3 x i8] c"wt\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"Failed to open device driver!\0A\00"
define void @display(i8* %0) {
%2 = alloca [100 x i8]
%3 = alloca [17 x i8]
%4 = tail call i32 @strlen(i8* %0)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %1
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = icmp sgt i32 %4, 0
br i1 %12, label %17, label %20
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %9
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 15
%19 = zext i32 %4 to i64
br label %20
20: ; preds = %17, %9
%21 = add i32 %4, 15
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %22
store i8 32, i8* %23
%24 = add i32 %4, 16
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
store i8 32, i8* %26
%27 = add i32 %4, 17
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %28
store i8 32, i8* %29
%30 = add i32 %4, 18
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %31
store i8 32, i8* %32
%33 = add i32 %4, 19
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %34
store i8 32, i8* %35
%36 = add i32 %4, 20
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %37
store i8 32, i8* %38
%39 = add i32 %4, 21
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %40
store i8 32, i8* %41
%42 = add i32 %4, 22
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %43
store i8 32, i8* %44
%45 = add i32 %4, 23
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %46
store i8 32, i8* %47
%48 = add i32 %4, 24
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %49
store i8 32, i8* %50
%51 = add i32 %4, 25
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %52
store i8 32, i8* %53
%54 = add i32 %4, 26
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %55
store i8 32, i8* %56
%57 = add i32 %4, 27
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %58
store i8 32, i8* %59
%60 = add i32 %4, 28
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %61
store i8 32, i8* %62
%63 = add i32 %4, 29
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %64
store i8 32, i8* %65
%66 = icmp sgt i32 %4, -15
br i1 %66, label %67, label %83
67: ; preds = %20
%68 = add i32 %4, 14
%69 = call i32 @llvm.smax.i32(i32 %68, i32 0)
%70 = add nuw i32 %69, 1
%71 = zext i32 %70 to i64
br label %72
72: ; preds = %67, %72
%73 = phi i64 [ 0, %67 ], [ %81, %72 ]
%74 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %73
%75 = call i32 @fwrite(i8* %74, i32 1, i32 18, i32* %7)
%76 = tail call i32 @fflush(i32* %7)
%77 = tail call i32 @usleep(i32 500000)
%78 = call i32 @fwrite(i8* %6, i32 1, i32 18, i32* %7)
%79 = tail call i32 @fflush(i32* %7)
%80 = tail call i32 @usleep(i32 160000)
%81 = add nuw nsw i64 %73, 1
%82 = icmp eq i64 %81, %71
br i1 %82, label %83, label %72
83: ; preds = %72, %20
%84 = tail call i32 @fclose(i32* %7)
ret void
}