#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 uint8_t;
typedef int uint32_t;
typedef int uint16_t;
typedef int int8_t;

/* Variables and functions */
uint16_t I2C_Recv2(int8_t slave) {
  uint8_t data1, data2;
  int retryCounter = 1;
  do {
    while ((*((volatile uint32_t *)0x40021004)) & 0x00000001) {
    };
    (*((volatile uint32_t *)0x40021000)) = (slave << 1) & 0xFE;
    (*((volatile uint32_t *)0x40021000)) |= 0x01;
    (*((volatile uint32_t *)0x40021004)) =
        (0 | 0x00000008 | 0x00000002 | 0x00000001);
    while ((*((volatile uint32_t *)0x40021004)) & 0x00000001) {
    };
    data1 = ((*((volatile uint32_t *)0x40021008)) & 0xFF);
    (*((volatile uint32_t *)0x40021004)) = (0 | 0x00000004 | 0x00000001);
    while ((*((volatile uint32_t *)0x40021004)) & 0x00000001) {
    };
    data2 = ((*((volatile uint32_t *)0x40021008)) & 0xFF);
    retryCounter = retryCounter + 1;
  } while ((((*((volatile uint32_t *)0x40021004)) &
             (0x00000004 | 0x00000002)) != 0) &&
           (retryCounter <= 5));
  return (data1 << 8) + data2;
}


x86 assembly (clang, -O0):
<I2C_Recv2>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
jmp    1113 <I2C_Recv2+0x13>
mov    $0x40021004,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     112b <I2C_Recv2+0x2b>
jmp    1113 <I2C_Recv2+0x13>
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
and    $0xfe,%ecx
mov    $0x40021000,%eax
mov    %ecx,(%rax)
mov    $0x40021000,%eax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    $0x40021000,%eax
mov    %ecx,(%rax)
mov    $0x40021004,%eax
movl   $0xb,(%rax)
mov    $0x40021004,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1172 <I2C_Recv2+0x72>
jmp    115a <I2C_Recv2+0x5a>
mov    $0x40021008,%eax
mov    (%rax),%eax
and    $0xff,%eax
mov    %eax,-0x8(%rbp)
mov    $0x40021004,%eax
movl   $0x5,(%rax)
mov    $0x40021004,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a4 <I2C_Recv2+0xa4>
jmp    118c <I2C_Recv2+0x8c>
mov    $0x40021008,%eax
mov    (%rax),%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x40021004,%eax
mov    (%rax),%ecx
and    $0x6,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     11de <I2C_Recv2+0xde>
cmpl   $0x5,-0x10(%rbp)
setle  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    110e <I2C_Recv2+0xe>
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
add    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<I2C_Recv2>:
add    %edi,%edi
movzbl %dil,%eax
cs nopw 0x0(%rax,%rax,1)
mov    0x40021004,%ecx
test   $0x1,%cl
jne    1110 <I2C_Recv2+0x10>
mov    %eax,0x40021000
orl    $0x1,0x40021000
01
movl   $0xb,0x40021004
cs nopw 0x0(%rax,%rax,1)
mov    0x40021004,%ecx
test   $0x1,%cl
jne    1140 <I2C_Recv2+0x40>
mov    0x40021008,%ecx
movl   $0x5,0x40021004
xchg   %ax,%ax
mov    0x40021004,%edx
test   $0x1,%dl
jne    1160 <I2C_Recv2+0x60>
mov    0x40021008,%edx
testl  $0x6,0x40021004
je     1369 <I2C_Recv2+0x269>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x40021004,%ecx
test   $0x1,%cl
jne    1190 <I2C_Recv2+0x90>
mov    %eax,0x40021000
orl    $0x1,0x40021000
01
movl   $0xb,0x40021004
cs nopw 0x0(%rax,%rax,1)
mov    0x40021004,%ecx
test   $0x1,%cl
jne    11c0 <I2C_Recv2+0xc0>
mov    0x40021008,%ecx
movl   $0x5,0x40021004
xchg   %ax,%ax
mov    0x40021004,%edx
test   $0x1,%dl
jne    11e0 <I2C_Recv2+0xe0>
mov    0x40021008,%edx
testl  $0x6,0x40021004
je     1369 <I2C_Recv2+0x269>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x40021004,%ecx
test   $0x1,%cl
jne    1210 <I2C_Recv2+0x110>
mov    %eax,0x40021000
orl    $0x1,0x40021000
01
movl   $0xb,0x40021004
cs nopw 0x0(%rax,%rax,1)
mov    0x40021004,%ecx
test   $0x1,%cl
jne    1240 <I2C_Recv2+0x140>
mov    0x40021008,%ecx
movl   $0x5,0x40021004
xchg   %ax,%ax
mov    0x40021004,%edx
test   $0x1,%dl
jne    1260 <I2C_Recv2+0x160>
mov    0x40021008,%edx
testl  $0x6,0x40021004
je     1369 <I2C_Recv2+0x269>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x40021004,%ecx
test   $0x1,%cl
jne    1290 <I2C_Recv2+0x190>
mov    %eax,0x40021000
orl    $0x1,0x40021000
01
movl   $0xb,0x40021004
cs nopw 0x0(%rax,%rax,1)
mov    0x40021004,%ecx
test   $0x1,%cl
jne    12c0 <I2C_Recv2+0x1c0>
mov    0x40021008,%ecx
movl   $0x5,0x40021004
xchg   %ax,%ax
mov    0x40021004,%edx
test   $0x1,%dl
jne    12e0 <I2C_Recv2+0x1e0>
mov    0x40021008,%edx
testl  $0x6,0x40021004
je     1369 <I2C_Recv2+0x269>
mov    0x40021004,%ecx
test   $0x1,%cl
jne    1300 <I2C_Recv2+0x200>
mov    %eax,0x40021000
orl    $0x1,0x40021000
01
movl   $0xb,0x40021004
cs nopw 0x0(%rax,%rax,1)
mov    0x40021004,%eax
test   $0x1,%al
jne    1330 <I2C_Recv2+0x230>
mov    0x40021008,%ecx
movl   $0x5,0x40021004
nopl   (%rax)
mov    0x40021004,%eax
test   $0x1,%al
jne    1350 <I2C_Recv2+0x250>
mov    0x40021008,%edx
mov    0x40021004,%eax
movzbl %dl,%edx
shl    $0x8,%ecx
movzwl %cx,%eax
or     %edx,%eax
ret

LLVM IR (-O0):
define i32 @I2C_Recv2(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %5
br label %6
6: ; preds = %43, %1
br label %7
7: ; preds = %11, %6
%8 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%9 = and i32 %8, 1
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
br label %7
12: ; preds = %7
%13 = load i32, i32* %2
%14 = shl i32 %13, 1
%15 = and i32 %14, 254
store volatile i32 %15, i32* inttoptr (i64 1073876992 to i32*)
%16 = load volatile i32, i32* inttoptr (i64 1073876992 to i32*)
%17 = or i32 %16, 1
store volatile i32 %17, i32* inttoptr (i64 1073876992 to i32*)
store volatile i32 11, i32* inttoptr (i64 1073876996 to i32*)
br label %18
18: ; preds = %22, %12
%19 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
br label %18
23: ; preds = %18
%24 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
%25 = and i32 %24, 255
store i32 %25, i32* %3
store volatile i32 5, i32* inttoptr (i64 1073876996 to i32*)
br label %26
26: ; preds = %30, %23
%27 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%28 = and i32 %27, 1
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
br label %26
31: ; preds = %26
%32 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
%33 = and i32 %32, 255
store i32 %33, i32* %4
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %36
36: ; preds = %31
%37 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%38 = and i32 %37, 6
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* %5
%42 = icmp sle i32 %41, 5
br label %43
43: ; preds = %40, %36
%44 = phi i1 [ false, %36 ], [ %42, %40 ]
br i1 %44, label %6, label %45
45: ; preds = %43
%46 = load i32, i32* %3
%47 = shl i32 %46, 8
%48 = load i32, i32* %4
%49 = add nsw i32 %47, %48
ret i32 %49
}

LLVM IR (-O2):
define i32 @I2C_Recv2(i32 %0) {
%2 = shl i32 %0, 1
%3 = and i32 %2, 254
br label %4
4: ; preds = %4, %1
%5 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %4
8: ; preds = %4
store volatile i32 %3, i32* inttoptr (i64 1073876992 to i32*)
%9 = load volatile i32, i32* inttoptr (i64 1073876992 to i32*)
%10 = or i32 %9, 1
store volatile i32 %10, i32* inttoptr (i64 1073876992 to i32*)
store volatile i32 11, i32* inttoptr (i64 1073876996 to i32*)
br label %11
11: ; preds = %11, %8
%12 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%13 = and i32 %12, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %11
15: ; preds = %11
%16 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
store volatile i32 5, i32* inttoptr (i64 1073876996 to i32*)
br label %17
17: ; preds = %17, %15
%18 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%19 = and i32 %18, 1
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %17
21: ; preds = %17
%22 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
%23 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%24 = and i32 %23, 6
%25 = icmp eq i32 %24, 0
br i1 %25, label %112, label %26
26: ; preds = %21, %26
%27 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%28 = and i32 %27, 1
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %26
30: ; preds = %26
store volatile i32 %3, i32* inttoptr (i64 1073876992 to i32*)
%31 = load volatile i32, i32* inttoptr (i64 1073876992 to i32*)
%32 = or i32 %31, 1
store volatile i32 %32, i32* inttoptr (i64 1073876992 to i32*)
store volatile i32 11, i32* inttoptr (i64 1073876996 to i32*)
br label %33
33: ; preds = %33, %30
%34 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%35 = and i32 %34, 1
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %33
37: ; preds = %33
%38 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
store volatile i32 5, i32* inttoptr (i64 1073876996 to i32*)
br label %39
39: ; preds = %39, %37
%40 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%41 = and i32 %40, 1
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %39
43: ; preds = %39
%44 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
%45 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%46 = and i32 %45, 6
%47 = icmp eq i32 %46, 0
br i1 %47, label %112, label %48
48: ; preds = %43, %48
%49 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%50 = and i32 %49, 1
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %48
52: ; preds = %48
store volatile i32 %3, i32* inttoptr (i64 1073876992 to i32*)
%53 = load volatile i32, i32* inttoptr (i64 1073876992 to i32*)
%54 = or i32 %53, 1
store volatile i32 %54, i32* inttoptr (i64 1073876992 to i32*)
store volatile i32 11, i32* inttoptr (i64 1073876996 to i32*)
br label %55
55: ; preds = %55, %52
%56 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%57 = and i32 %56, 1
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %55
59: ; preds = %55
%60 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
store volatile i32 5, i32* inttoptr (i64 1073876996 to i32*)
br label %61
61: ; preds = %61, %59
%62 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%63 = and i32 %62, 1
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %61
65: ; preds = %61
%66 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
%67 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%68 = and i32 %67, 6
%69 = icmp eq i32 %68, 0
br i1 %69, label %112, label %70
70: ; preds = %65, %70
%71 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%72 = and i32 %71, 1
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %70
74: ; preds = %70
store volatile i32 %3, i32* inttoptr (i64 1073876992 to i32*)
%75 = load volatile i32, i32* inttoptr (i64 1073876992 to i32*)
%76 = or i32 %75, 1
store volatile i32 %76, i32* inttoptr (i64 1073876992 to i32*)
store volatile i32 11, i32* inttoptr (i64 1073876996 to i32*)
br label %77
77: ; preds = %77, %74
%78 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%79 = and i32 %78, 1
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %77
81: ; preds = %77
%82 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
store volatile i32 5, i32* inttoptr (i64 1073876996 to i32*)
br label %83
83: ; preds = %83, %81
%84 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%85 = and i32 %84, 1
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %83
87: ; preds = %83
%88 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
%89 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%90 = and i32 %89, 6
%91 = icmp eq i32 %90, 0
br i1 %91, label %112, label %92
92: ; preds = %87, %92
%93 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%94 = and i32 %93, 1
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %92
96: ; preds = %92
store volatile i32 %3, i32* inttoptr (i64 1073876992 to i32*)
%97 = load volatile i32, i32* inttoptr (i64 1073876992 to i32*)
%98 = or i32 %97, 1
store volatile i32 %98, i32* inttoptr (i64 1073876992 to i32*)
store volatile i32 11, i32* inttoptr (i64 1073876996 to i32*)
br label %99
99: ; preds = %99, %96
%100 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%101 = and i32 %100, 1
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %99
103: ; preds = %99
%104 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
store volatile i32 5, i32* inttoptr (i64 1073876996 to i32*)
br label %105
105: ; preds = %105, %103
%106 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
%107 = and i32 %106, 1
%108 = icmp eq i32 %107, 0
br i1 %108, label %109, label %105
109: ; preds = %105
%110 = load volatile i32, i32* inttoptr (i64 1073877000 to i32*)
%111 = load volatile i32, i32* inttoptr (i64 1073876996 to i32*)
br label %112
112: ; preds = %109, %87, %65, %43, %21
%113 = phi i32 [ %22, %21 ], [ %44, %43 ], [ %66, %65 ], [ %88, %87 ], [ %110, %109 ]
%114 = phi i32 [ %16, %21 ], [ %38, %43 ], [ %60, %65 ], [ %82, %87 ], [ %104, %109 ]
%115 = and i32 %113, 255
%116 = shl i32 %114, 8
%117 = and i32 %116, 65280
%118 = or i32 %115, %117
ret i32 %118
}