#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ i2c_deinit();
int /*<<< orphan*/ i2c_getopt(int, char **);
int /*<<< orphan*/ i2c_hw_start();
int /*<<< orphan*/ i2c_hw_stop();
scalar_t__ i2c_hw_tx_byte(unsigned char);
int /*<<< orphan*/ i2c_init();
int /*<<< orphan*/ printf(char *, unsigned char);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  unsigned char id, i2cid;
  i2c_getopt(argc, argv);
  i2c_init();
  fputs("     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f", stdout);
  for (id = 0; id < 128; id++) {
    i2cid = (id << 1) | 1;
    fflush(stdout);
    if ((id & 0x0f) == 0) {
      printf("\n%02x:", id);
    }
    i2c_hw_start();
    if (i2c_hw_tx_byte(i2cid))
      printf(" %02x", id);
    else
      fputs(" --", stdout);
  }
  fputs("\n", stdout);
  i2c_hw_stop();
  i2c_deinit();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1080 <i2c_getopt@plt>
mov    $0x0,%al
call   1030 <i2c_init@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
lea    0xe37(%rip),%rdi
call   1050 <fputs@plt>
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x80,%eax
jge    1272 <main+0xe2>
movzbl -0x11(%rbp),%eax
shl    $0x1,%eax
or     $0x1,%eax
mov    %al,-0x12(%rbp)
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
movzbl -0x11(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    121c <main+0x8c>
lea    0xe21(%rip),%rdi
movzbl -0x11(%rbp),%esi
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <i2c_hw_start@plt>
movzbl -0x12(%rbp),%edi
call   1090 <i2c_hw_tx_byte@plt>
cmp    $0x0,%rax
je     124b <main+0xbb>
lea    0xdfe(%rip),%rdi
movzbl -0x11(%rbp),%esi
call   1040 <printf@plt>
jmp    1260 <main+0xd0>
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
lea    0xde6(%rip),%rdi
call   1050 <fputs@plt>
jmp    1265 <main+0xd5>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    11d2 <main+0x42>
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
lea    0xdc3(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x0,%al
call   1060 <i2c_hw_stop@plt>
mov    $0x0,%al
call   10b0 <i2c_deinit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
call   1080 <i2c_getopt@plt>
xor    %eax,%eax
call   1030 <i2c_init@plt>
mov    0x2e32(%rip),%r13
mov    0x0(%r13),%esi
lea    0xe47(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x1,%bl
lea    0xe6d(%rip),%r14
lea    0xe73(%rip),%r15
lea    0xe66(%rip),%r12
xor    %ebp,%ebp
jmp    11f9 <main+0x69>
nopl   0x0(%rax)
mov    0x0(%r13),%esi
mov    %r15,%rdi
call   1050 <fputs@plt>
add    $0x1,%bpl
add    $0x2,%bl
cmp    $0x80,%bpl
je     1236 <main+0xa6>
mov    0x0(%r13),%edi
call   1070 <fflush@plt>
test   $0xf,%bpl
jne    1214 <main+0x84>
movzbl %bpl,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   10a0 <i2c_hw_start@plt>
movzbl %bl,%edi
call   1090 <i2c_hw_tx_byte@plt>
test   %rax,%rax
je     11e0 <main+0x50>
movzbl %bpl,%esi
mov    %r12,%rdi
call   1040 <printf@plt>
jmp    11ec <main+0x5c>
mov    0x0(%r13),%esi
lea    0xe04(%rip),%rdi
call   1050 <fputs@plt>
xor    %eax,%eax
call   1060 <i2c_hw_stop@plt>
xor    %eax,%eax
call   10b0 <i2c_deinit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c" 0 1 2 3 4 5 6 7 8 9 a b c d e f\00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"\0A%02x:\00"
@.str.2 = [6 x i8] c" %02x\00"
@.str.3 = [4 x i8] c" --\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @i2c_getopt(i32 %8, i8** %9)
%11 = call i32 (...) @i2c_init()
%12 = load i32, i32* @stdout
%13 = call i32 @fputs(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %12)
store i8 0, i8* %6
br label %14
14: ; preds = %45, %2
%15 = load i8, i8* %6
%16 = zext i8 %15 to i32
%17 = icmp slt i32 %16, 128
br i1 %17, label %18, label %48
18: ; preds = %14
%19 = load i8, i8* %6
%20 = zext i8 %19 to i32
%21 = shl i32 %20, 1
%22 = or i32 %21, 1
%23 = trunc i32 %22 to i8
store i8 %23, i8* %7
%24 = load i32, i32* @stdout
%25 = call i32 @fflush(i32 %24)
%26 = load i8, i8* %6
%27 = zext i8 %26 to i32
%28 = and i32 %27, 15
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %18
%31 = load i8, i8* %6
%32 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %31)
br label %33
33: ; preds = %30, %18
%34 = call i32 (...) @i2c_hw_start()
%35 = load i8, i8* %7
%36 = call i64 @i2c_hw_tx_byte(i8 zeroext %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i8, i8* %6
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %39)
br label %44
41: ; preds = %33
%42 = load i32, i32* @stdout
%43 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41, %38
br label %45
45: ; preds = %44
%46 = load i8, i8* %6
%47 = add i8 %46, 1
store i8 %47, i8* %6
br label %14
48: ; preds = %14
%49 = load i32, i32* @stdout
%50 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%51 = call i32 (...) @i2c_hw_stop()
%52 = call i32 (...) @i2c_deinit()
ret i32 0
}

LLVM IR (-O2):
@.str = [52 x i8] c" 0 1 2 3 4 5 6 7 8 9 a b c d e f\00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"\0A%02x:\00"
@.str.2 = [6 x i8] c" %02x\00"
@.str.3 = [4 x i8] c" --\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @i2c_getopt(i32 %0, i8** %1)
%4 = tail call i32 (...) @i2c_init()
%5 = load i32, i32* @stdout
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %2, %26
%8 = phi i8 [ 0, %2 ], [ %27, %26 ]
%9 = shl nuw i8 %8, 1
%10 = or i8 %9, 1
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
%13 = and i8 %8, 15
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %7
%16 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %8)
br label %17
17: ; preds = %15, %7
%18 = tail call i32 (...) @i2c_hw_start()
%19 = tail call i64 @i2c_hw_tx_byte(i8 zeroext %10)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %8)
br label %26
23: ; preds = %17
%24 = load i32, i32* @stdout
%25 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %21, %23
%27 = add nuw i8 %8, 1
%28 = icmp eq i8 %27, -128
br i1 %28, label %29, label %7
29: ; preds = %26
%30 = load i32, i32* @stdout
%31 = tail call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = tail call i32 (...) @i2c_hw_stop()
%33 = tail call i32 (...) @i2c_deinit()
ret i32 0
}