#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 decode_digit(unsigned char const, unsigned char const);
int /*<<< orphan*/ printf(char *, ...);
int print_display_number(const unsigned char *buf) {
  int n;
  int val;
  for (n = 1; n < 8; n += 2) {
    if (buf[n] & 0x8) {
      if (n == 1)
        printf("-");
      else
        printf(".");
    }
    val = decode_digit(buf[n], buf[n + 1]);
    if (val == -1) {
      printf("Unknown digit %X %X\n", buf[n], buf[n + 1]);
      return -1;
    } else {
      if (val < 10)
        printf("%d", val);
      else {
        if (val == 10)
          printf("L");
        if (val == 11)
          printf(" ");
        if (val > 11)
          printf("?");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<print_display_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1272 <print_display_number+0x152>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1185 <print_display_number+0x65>
cmpl   $0x1,-0x14(%rbp)
jne    1172 <print_display_number+0x52>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <print_display_number+0x60>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1185 <print_display_number+0x65>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl %dl,%edi
movzbl (%rax,%rcx,1),%esi
call   1040 <decode_digit@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11ed <print_display_number+0xcd>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1279 <print_display_number+0x159>
cmpl   $0xa,-0x18(%rbp)
jge    120d <print_display_number+0xed>
mov    -0x18(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125a <print_display_number+0x13a>
cmpl   $0xa,-0x18(%rbp)
jne    1225 <print_display_number+0x105>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xb,-0x18(%rbp)
jne    123d <print_display_number+0x11d>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xb,-0x18(%rbp)
jle    1255 <print_display_number+0x135>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125a <print_display_number+0x13a>
jmp    125f <print_display_number+0x13f>
jmp    1264 <print_display_number+0x144>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <print_display_number+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_display_number>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x1(%rdi),%r14
mov    0x1(%rdi),%al
test   $0x8,%al
je     114f <print_display_number+0x1f>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    (%r14),%al
movzbl 0x2(%rbx),%esi
movzbl %al,%edi
call   1050 <decode_digit@plt>
cmp    $0xffffffff,%eax
je     1177 <print_display_number+0x47>
cmp    $0x9,%eax
jg     1181 <print_display_number+0x51>
lea    0xea9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a3 <print_display_number+0x73>
mov    $0x2,%eax
jmp    12b9 <print_display_number+0x189>
cmp    $0xb,%eax
je     1192 <print_display_number+0x62>
cmp    $0xa,%eax
jne    1199 <print_display_number+0x69>
mov    $0x4c,%edi
jmp    119e <print_display_number+0x6e>
mov    $0x20,%edi
jmp    119e <print_display_number+0x6e>
mov    $0x3f,%edi
call   1030 <putchar@plt>
lea    0x3(%rbx),%r14
mov    0x3(%rbx),%al
test   $0x8,%al
je     11bb <print_display_number+0x8b>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    (%r14),%al
movzbl 0x4(%rbx),%esi
movzbl %al,%edi
call   1050 <decode_digit@plt>
cmp    $0xffffffff,%eax
je     11e3 <print_display_number+0xb3>
cmp    $0xa,%eax
jge    11ed <print_display_number+0xbd>
lea    0xe3d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    120c <print_display_number+0xdc>
mov    $0x4,%eax
jmp    12b9 <print_display_number+0x189>
je     11fb <print_display_number+0xcb>
cmp    $0xb,%eax
jne    1202 <print_display_number+0xd2>
mov    $0x20,%edi
jmp    1207 <print_display_number+0xd7>
mov    $0x4c,%edi
jmp    1207 <print_display_number+0xd7>
mov    $0x3f,%edi
call   1030 <putchar@plt>
lea    0x5(%rbx),%r14
mov    0x5(%rbx),%al
test   $0x8,%al
je     1224 <print_display_number+0xf4>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    (%r14),%al
movzbl 0x6(%rbx),%esi
movzbl %al,%edi
call   1050 <decode_digit@plt>
cmp    $0xffffffff,%eax
je     124c <print_display_number+0x11c>
cmp    $0xa,%eax
jge    1253 <print_display_number+0x123>
lea    0xdd4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1272 <print_display_number+0x142>
mov    $0x6,%eax
jmp    12b9 <print_display_number+0x189>
je     1261 <print_display_number+0x131>
cmp    $0xb,%eax
jne    1268 <print_display_number+0x138>
mov    $0x20,%edi
jmp    126d <print_display_number+0x13d>
mov    $0x4c,%edi
jmp    126d <print_display_number+0x13d>
mov    $0x3f,%edi
call   1030 <putchar@plt>
lea    0x7(%rbx),%r14
mov    0x7(%rbx),%al
test   $0x8,%al
je     128a <print_display_number+0x15a>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    (%r14),%al
movzbl 0x8(%rbx),%esi
movzbl %al,%edi
call   1050 <decode_digit@plt>
cmp    $0xffffffff,%eax
je     12b4 <print_display_number+0x184>
cmp    $0xa,%eax
jge    12de <print_display_number+0x1ae>
lea    0xd6e(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12d4 <print_display_number+0x1a4>
mov    $0x8,%eax
movzbl (%r14),%esi
movzbl (%rbx,%rax,1),%edx
lea    0xd38(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
je     12ec <print_display_number+0x1bc>
cmp    $0xb,%eax
jne    12f3 <print_display_number+0x1c3>
mov    $0x20,%edi
jmp    12f8 <print_display_number+0x1c8>
mov    $0x4c,%edi
jmp    12f8 <print_display_number+0x1c8>
mov    $0x3f,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    12d4 <print_display_number+0x1a4>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [21 x i8] c"Unknown digit %X %X\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [2 x i8] c"L\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [2 x i8] c"?\00"
define i32 @print_display_number(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 1, i32* %4
br label %6
6: ; preds = %80, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %83
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = and i32 %15, 8
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %9
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %25
23: ; preds = %18
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %21
br label %26
26: ; preds = %25, %9
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = load i8*, i8** %3
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @decode_digit(i8 zeroext %31, i8 zeroext %37)
store i32 %38, i32* %5
%39 = load i32, i32* %5
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %56
41: ; preds = %26
%42 = load i8*, i8** %3
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = load i8*, i8** %3
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %47, i32 %54)
store i32 -1, i32* %2
br label %84
56: ; preds = %26
%57 = load i32, i32* %5
%58 = icmp slt i32 %57, 10
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32, i32* %5
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %60)
br label %78
62: ; preds = %56
%63 = load i32, i32* %5
%64 = icmp eq i32 %63, 10
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %67
67: ; preds = %65, %62
%68 = load i32, i32* %5
%69 = icmp eq i32 %68, 11
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %72
72: ; preds = %70, %67
%73 = load i32, i32* %5
%74 = icmp sgt i32 %73, 11
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %77
77: ; preds = %75, %72
br label %78
78: ; preds = %77, %59
br label %79
79: ; preds = %78
br label %80
80: ; preds = %79
%81 = load i32, i32* %4
%82 = add nsw i32 %81, 2
store i32 %82, i32* %4
br label %6
83: ; preds = %6
store i32 0, i32* %2
br label %84
84: ; preds = %83, %41
%85 = load i32, i32* %2
ret i32 %85
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"Unknown digit %X %X\0A\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @print_display_number(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = load i8, i8* %2
%4 = and i8 %3, 8
%5 = icmp eq i8 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = tail call i32 @putchar(i32 45)
%8 = load i8, i8* %2
br label %9
9: ; preds = %6, %1
%10 = phi i8 [ %8, %6 ], [ %3, %1 ]
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = load i8, i8* %11
%13 = tail call i32 @decode_digit(i8 zeroext %10, i8 zeroext %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %24
15: ; preds = %93, %68, %43, %9
%16 = phi i64 [ 2, %9 ], [ 4, %43 ], [ 6, %68 ], [ 8, %93 ]
%17 = phi i8* [ %2, %9 ], [ %36, %43 ], [ %61, %68 ], [ %86, %93 ]
%18 = getelementptr inbounds i8, i8* %0, i64 %16
%19 = load i8, i8* %17
%20 = zext i8 %19 to i32
%21 = load i8, i8* %18
%22 = zext i8 %21 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %22)
br label %110
24: ; preds = %9
%25 = icmp slt i32 %13, 10
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %35
28: ; preds = %24
switch i32 %13, label %33 [
i32 10, label %29
i32 11, label %31
]
29: ; preds = %28
%30 = tail call i32 @putchar(i32 76)
br label %35
31: ; preds = %28
%32 = tail call i32 @putchar(i32 32)
br label %35
33: ; preds = %28
%34 = tail call i32 @putchar(i32 63)
br label %35
35: ; preds = %31, %29, %33, %26
%36 = getelementptr inbounds i8, i8* %0, i64 3
%37 = load i8, i8* %36
%38 = and i8 %37, 8
%39 = icmp eq i8 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %35
%41 = tail call i32 @putchar(i32 46)
%42 = load i8, i8* %36
br label %43
43: ; preds = %40, %35
%44 = phi i8 [ %42, %40 ], [ %37, %35 ]
%45 = getelementptr inbounds i8, i8* %0, i64 4
%46 = load i8, i8* %45
%47 = tail call i32 @decode_digit(i8 zeroext %44, i8 zeroext %46)
%48 = icmp eq i32 %47, -1
br i1 %48, label %15, label %49
49: ; preds = %43
%50 = icmp slt i32 %47, 10
br i1 %50, label %58, label %51
51: ; preds = %49
switch i32 %47, label %56 [
i32 10, label %54
i32 11, label %52
]
52: ; preds = %51
%53 = tail call i32 @putchar(i32 32)
br label %60
54: ; preds = %51
%55 = tail call i32 @putchar(i32 76)
br label %60
56: ; preds = %51
%57 = tail call i32 @putchar(i32 63)
br label %60
58: ; preds = %49
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %47)
br label %60
60: ; preds = %58, %56, %54, %52
%61 = getelementptr inbounds i8, i8* %0, i64 5
%62 = load i8, i8* %61
%63 = and i8 %62, 8
%64 = icmp eq i8 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %60
%66 = tail call i32 @putchar(i32 46)
%67 = load i8, i8* %61
br label %68
68: ; preds = %65, %60
%69 = phi i8 [ %67, %65 ], [ %62, %60 ]
%70 = getelementptr inbounds i8, i8* %0, i64 6
%71 = load i8, i8* %70
%72 = tail call i32 @decode_digit(i8 zeroext %69, i8 zeroext %71)
%73 = icmp eq i32 %72, -1
br i1 %73, label %15, label %74
74: ; preds = %68
%75 = icmp slt i32 %72, 10
br i1 %75, label %83, label %76
76: ; preds = %74
switch i32 %72, label %81 [
i32 10, label %79
i32 11, label %77
]
77: ; preds = %76
%78 = tail call i32 @putchar(i32 32)
br label %85
79: ; preds = %76
%80 = tail call i32 @putchar(i32 76)
br label %85
81: ; preds = %76
%82 = tail call i32 @putchar(i32 63)
br label %85
83: ; preds = %74
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %72)
br label %85
85: ; preds = %83, %81, %79, %77
%86 = getelementptr inbounds i8, i8* %0, i64 7
%87 = load i8, i8* %86
%88 = and i8 %87, 8
%89 = icmp eq i8 %88, 0
br i1 %89, label %93, label %90
90: ; preds = %85
%91 = tail call i32 @putchar(i32 46)
%92 = load i8, i8* %86
br label %93
93: ; preds = %90, %85
%94 = phi i8 [ %92, %90 ], [ %87, %85 ]
%95 = getelementptr inbounds i8, i8* %0, i64 8
%96 = load i8, i8* %95
%97 = tail call i32 @decode_digit(i8 zeroext %94, i8 zeroext %96)
%98 = icmp eq i32 %97, -1
br i1 %98, label %15, label %99
99: ; preds = %93
%100 = icmp slt i32 %97, 10
br i1 %100, label %108, label %101
101: ; preds = %99
switch i32 %97, label %106 [
i32 10, label %104
i32 11, label %102
]
102: ; preds = %101
%103 = tail call i32 @putchar(i32 32)
br label %110
104: ; preds = %101
%105 = tail call i32 @putchar(i32 76)
br label %110
106: ; preds = %101
%107 = tail call i32 @putchar(i32 63)
br label %110
108: ; preds = %99
%109 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %97)
br label %110
110: ; preds = %102, %104, %106, %108, %15
%111 = phi i32 [ -1, %15 ], [ 0, %108 ], [ 0, %106 ], [ 0, %104 ], [ 0, %102 ]
ret i32 %111
}