#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*/ fail(int);
int /*<<< orphan*/ report_device(int);
grcan_test(int paddr) {
  report_device(0x0103D000);
  struct grcan_ctrl {
    volatile unsigned long conf;
    volatile unsigned long stat;
    volatile unsigned long ctrl;
    volatile unsigned long dummy0c;
    volatile unsigned long dummy10;
    volatile unsigned long dummy14;
    volatile unsigned long smask;
    volatile unsigned long scode;
  };
  struct grcan_irq {
    volatile unsigned long pimsr;
    volatile unsigned long pimr;
    volatile unsigned long pisr;
    volatile unsigned long pir;
    volatile unsigned long imr;
    volatile unsigned long picr;
  };
  struct grcan_tx {
    volatile unsigned long ctrl;
    volatile unsigned long addr;
    volatile unsigned long size;
    volatile unsigned long wr;
    volatile unsigned long rd;
    volatile unsigned long irq;
  };
  struct grcan_ctrl *lctrl = (struct grcan_ctrl *)(paddr);
  struct grcan_irq *lirq = (struct grcan_irq *)(paddr + 0x100);
  struct grcan_tx *ltx0 = (struct grcan_tx *)(paddr + 0x200);
  volatile long int memory[512];
  long int memorytxbase;
  memorytxbase = (long int)&memory[0];
  memorytxbase = memorytxbase & 0xFFFFFC00;
  memorytxbase = memorytxbase + 0x400;
  int SCALER = 0;
  int PS1 = 2;
  int PS2 = 2;
  int RSJ = 1;
  int BPR = 0;
  int SELECTION = 0;
  int ENABLE = 0x1;
  volatile int *memorytx;
  memorytx = (int *)memorytxbase;
  *memorytx = 0x913579BD;
  memorytx++;
  *memorytx = 0x80000000;
  memorytx++;
  *memorytx = 0x01020304;
  memorytx++;
  *memorytx = 0x05060708;
  memorytx++;
  lctrl->ctrl = 0x00000002;
  lctrl->conf = (SCALER << 24) | (PS1 << 20) | (PS2 << 16) | (RSJ << 12) |
                (BPR << 8) | (SELECTION << 3) | (ENABLE << 1);
  lirq->picr = 0xFFFFFFFF;
  lctrl->ctrl = 0x00000001;
  ltx0->addr = memorytxbase;
  ltx0->size = 0x00000080;
  ltx0->irq = 0x00000010;
  ltx0->ctrl = 0x00000001;
  ltx0->wr = 0x00000010;
  while ((ltx0->rd & 0xFFFF) != 0x0010)
    ;
  if (lctrl->stat != 0x00000000)
    fail(1);
  if (lirq->pir != 0x00000540)
    fail(2);
  lirq->picr = 0xFFFFFFFF;
  SELECTION = 1;
  ENABLE = 2;
  lctrl->ctrl = 0x00000002;
  lctrl->conf = (SCALER << 24) | (PS1 << 20) | (PS2 << 16) | (RSJ << 12) |
                (BPR << 8) | (SELECTION << 3) | (ENABLE << 1);
  lirq->picr = 0xFFFFFFFF;
  lctrl->ctrl = 0x00000001;
  ltx0->addr = memorytxbase;
  ltx0->size = 0x00000080;
  ltx0->irq = 0x00000010;
  ltx0->ctrl = 0x00000001;
  ltx0->wr = 0x00000010;
  while ((ltx0->rd & 0xFFFF) != 0x0010)
    ;
  if (lctrl->stat != 0x00000000)
    fail(3);
  if (lirq->pir != 0x00000540)
    fail(4);
  lirq->picr = 0xFFFFFFFF;
  lctrl->ctrl = 0x00000002;
}


x86 assembly (clang, -O0):
<grcan_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x103d000,%edi
call   1030 <report_device@plt>
movslq -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x100,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x200,%eax
cltq
mov    %rax,-0x20(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1028(%rbp)
movabs $0xfffffc00,%rax
and    -0x1028(%rbp),%rax
mov    %rax,-0x1028(%rbp)
mov    -0x1028(%rbp),%rax
add    $0x400,%rax
mov    %rax,-0x1028(%rbp)
movl   $0x0,-0x102c(%rbp)
movl   $0x2,-0x1030(%rbp)
movl   $0x2,-0x1034(%rbp)
movl   $0x1,-0x1038(%rbp)
movl   $0x0,-0x103c(%rbp)
movl   $0x0,-0x1040(%rbp)
movl   $0x1,-0x1044(%rbp)
mov    -0x1028(%rbp),%rax
mov    %rax,-0x1050(%rbp)
mov    -0x1050(%rbp),%rax
movl   $0x913579bd,(%rax)
mov    -0x1050(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x1050(%rbp)
mov    -0x1050(%rbp),%rax
movl   $0x80000000,(%rax)
mov    -0x1050(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x1050(%rbp)
mov    -0x1050(%rbp),%rax
movl   $0x1020304,(%rax)
mov    -0x1050(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x1050(%rbp)
mov    -0x1050(%rbp),%rax
movl   $0x5060708,(%rax)
mov    -0x1050(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x1050(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x2,0x10(%rax)
mov    -0x102c(%rbp),%eax
shl    $0x18,%eax
mov    -0x1030(%rbp),%ecx
shl    $0x14,%ecx
or     %ecx,%eax
mov    -0x1034(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x1038(%rbp),%ecx
shl    $0xc,%ecx
or     %ecx,%eax
mov    -0x103c(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x1040(%rbp),%ecx
shl    $0x3,%ecx
or     %ecx,%eax
mov    -0x1044(%rbp),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    $0xffffffff,%ecx
mov    %rcx,0x28(%rax)
mov    -0x10(%rbp),%rax
movq   $0x1,0x10(%rax)
mov    -0x1028(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
movq   $0x80,0x10(%rax)
mov    -0x20(%rbp),%rax
movq   $0x10,0x28(%rax)
mov    -0x20(%rbp),%rax
movq   $0x1,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x10,0x18(%rax)
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%rax
and    $0xffff,%rax
cmp    $0x10,%rax
je     133b <grcan_test+0x21b>
jmp    131e <grcan_test+0x1fe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
cmp    $0x0,%rax
je     1357 <grcan_test+0x237>
mov    $0x1,%edi
call   1040 <fail@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmp    $0x540,%rax
je     1375 <grcan_test+0x255>
mov    $0x2,%edi
call   1040 <fail@plt>
mov    -0x18(%rbp),%rax
mov    $0xffffffff,%ecx
mov    %rcx,0x28(%rax)
movl   $0x1,-0x1040(%rbp)
movl   $0x2,-0x1044(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x2,0x10(%rax)
mov    -0x102c(%rbp),%eax
shl    $0x18,%eax
mov    -0x1030(%rbp),%ecx
shl    $0x14,%ecx
or     %ecx,%eax
mov    -0x1034(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x1038(%rbp),%ecx
shl    $0xc,%ecx
or     %ecx,%eax
mov    -0x103c(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x1040(%rbp),%ecx
shl    $0x3,%ecx
or     %ecx,%eax
mov    -0x1044(%rbp),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    $0xffffffff,%ecx
mov    %rcx,0x28(%rax)
mov    -0x10(%rbp),%rax
movq   $0x1,0x10(%rax)
mov    -0x1028(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
movq   $0x80,0x10(%rax)
mov    -0x20(%rbp),%rax
movq   $0x10,0x28(%rax)
mov    -0x20(%rbp),%rax
movq   $0x1,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x10,0x18(%rax)
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%rax
and    $0xffff,%rax
cmp    $0x10,%rax
je     146b <grcan_test+0x34b>
jmp    144e <grcan_test+0x32e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
cmp    $0x0,%rax
je     1487 <grcan_test+0x367>
mov    $0x3,%edi
call   1040 <fail@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmp    $0x540,%rax
je     14a5 <grcan_test+0x385>
mov    $0x4,%edi
call   1040 <fail@plt>
mov    -0x18(%rbp),%rax
mov    $0xffffffff,%ecx
mov    %rcx,0x28(%rax)
mov    -0x10(%rbp),%rax
movq   $0x2,0x10(%rax)
mov    -0x4(%rbp),%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grcan_test>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %edi,%ebx
mov    $0xffffffff,%r14d
mov    $0x103d000,%edi
call   1030 <report_device@plt>
movslq %ebx,%rbx
mov    %rsp,%rax
and    $0xfffffc00,%eax
lea    0x400(%rax),%r15
movl   $0x913579bd,0x400(%rax)
79 35 91
movl   $0x80000000,0x404(%rax)
movl   $0x1020304,0x408(%rax)
03 02 01
movl   $0x5060708,0x40c(%rax)
07 06 05
movq   $0x2,0x10(%rbx)
movq   $0x221002,(%rbx)
mov    %r14,0x128(%rbx)
movq   $0x1,0x10(%rbx)
mov    %r15,0x208(%rbx)
movq   $0x80,0x210(%rbx)
movq   $0x10,0x228(%rbx)
movq   $0x1,0x200(%rbx)
movq   $0x10,0x218(%rbx)
nopl   0x0(%rax)
mov    0x220(%rbx),%rax
cmp    $0x10,%ax
jne    11d0 <grcan_test+0xb0>
cmpq   $0x0,0x8(%rbx)
je     11ee <grcan_test+0xce>
mov    $0x1,%edi
call   1040 <fail@plt>
mov    0x118(%rbx),%rax
cmp    $0x540,%rax
je     1207 <grcan_test+0xe7>
mov    $0x2,%edi
call   1040 <fail@plt>
mov    %r14,0x128(%rbx)
movq   $0x2,0x10(%rbx)
movq   $0x22100c,(%rbx)
mov    %r14,0x128(%rbx)
movq   $0x1,0x10(%rbx)
mov    %r15,0x208(%rbx)
movq   $0x80,0x210(%rbx)
movq   $0x10,0x228(%rbx)
movq   $0x1,0x200(%rbx)
movq   $0x10,0x218(%rbx)
nop
mov    0x220(%rbx),%rax
cmp    $0x10,%ax
jne    1260 <grcan_test+0x140>
cmpq   $0x0,0x8(%rbx)
je     127e <grcan_test+0x15e>
mov    $0x3,%edi
call   1040 <fail@plt>
mov    0x118(%rbx),%rax
cmp    $0x540,%rax
je     1297 <grcan_test+0x177>
mov    $0x4,%edi
call   1040 <fail@plt>
mov    %r14,0x128(%rbx)
movq   $0x2,0x10(%rbx)
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.grcan_ctrl = type { i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.grcan_irq = type { i64, i64, i64, i64, i64, i64 }
%struct.grcan_tx = type { i64, i64, i64, i64, i64, i64 }
define i32 @grcan_test(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.grcan_ctrl*
%5 = alloca %struct.grcan_irq*
%6 = alloca %struct.grcan_tx*
%7 = alloca [512 x i64]
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
store i32 %0, i32* %3
%17 = call i32 @report_device(i32 17027072)
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to %struct.grcan_ctrl*
store %struct.grcan_ctrl* %20, %struct.grcan_ctrl** %4
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 256
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to %struct.grcan_irq*
store %struct.grcan_irq* %24, %struct.grcan_irq** %5
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 512
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to %struct.grcan_tx*
store %struct.grcan_tx* %28, %struct.grcan_tx** %6
%29 = getelementptr inbounds [512 x i64], [512 x i64]* %7, i64 0, i64 0
%30 = ptrtoint i64* %29 to i64
store i64 %30, i64* %8
%31 = load i64, i64* %8
%32 = and i64 %31, 4294966272
store i64 %32, i64* %8
%33 = load i64, i64* %8
%34 = add nsw i64 %33, 1024
store i64 %34, i64* %8
store i32 0, i32* %9
store i32 2, i32* %10
store i32 2, i32* %11
store i32 1, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 1, i32* %15
%35 = load i64, i64* %8
%36 = inttoptr i64 %35 to i32*
store i32* %36, i32** %16
%37 = load i32*, i32** %16
store volatile i32 -1858766403, i32* %37
%38 = load i32*, i32** %16
%39 = getelementptr inbounds i32, i32* %38, i32 1
store i32* %39, i32** %16
%40 = load i32*, i32** %16
store volatile i32 -2147483648, i32* %40
%41 = load i32*, i32** %16
%42 = getelementptr inbounds i32, i32* %41, i32 1
store i32* %42, i32** %16
%43 = load i32*, i32** %16
store volatile i32 16909060, i32* %43
%44 = load i32*, i32** %16
%45 = getelementptr inbounds i32, i32* %44, i32 1
store i32* %45, i32** %16
%46 = load i32*, i32** %16
store volatile i32 84281096, i32* %46
%47 = load i32*, i32** %16
%48 = getelementptr inbounds i32, i32* %47, i32 1
store i32* %48, i32** %16
%49 = load %struct.grcan_ctrl*, %struct.grcan_ctrl** %4
%50 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %49, i32 0, i32 2
store volatile i64 2, i64* %50
%51 = load i32, i32* %9
%52 = shl i32 %51, 24
%53 = load i32, i32* %10
%54 = shl i32 %53, 20
%55 = or i32 %52, %54
%56 = load i32, i32* %11
%57 = shl i32 %56, 16
%58 = or i32 %55, %57
%59 = load i32, i32* %12
%60 = shl i32 %59, 12
%61 = or i32 %58, %60
%62 = load i32, i32* %13
%63 = shl i32 %62, 8
%64 = or i32 %61, %63
%65 = load i32, i32* %14
%66 = shl i32 %65, 3
%67 = or i32 %64, %66
%68 = load i32, i32* %15
%69 = shl i32 %68, 1
%70 = or i32 %67, %69
%71 = sext i32 %70 to i64
%72 = load %struct.grcan_ctrl*, %struct.grcan_ctrl** %4
%73 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %72, i32 0, i32 0
store volatile i64 %71, i64* %73
%74 = load %struct.grcan_irq*, %struct.grcan_irq** %5
%75 = getelementptr inbounds %struct.grcan_irq, %struct.grcan_irq* %74, i32 0, i32 5
store volatile i64 4294967295, i64* %75
%76 = load %struct.grcan_ctrl*, %struct.grcan_ctrl** %4
%77 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %76, i32 0, i32 2
store volatile i64 1, i64* %77
%78 = load i64, i64* %8
%79 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%80 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %79, i32 0, i32 1
store volatile i64 %78, i64* %80
%81 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%82 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %81, i32 0, i32 2
store volatile i64 128, i64* %82
%83 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%84 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %83, i32 0, i32 5
store volatile i64 16, i64* %84
%85 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%86 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %85, i32 0, i32 0
store volatile i64 1, i64* %86
%87 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%88 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %87, i32 0, i32 3
store volatile i64 16, i64* %88
br label %89
89: ; preds = %95, %1
%90 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%91 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %90, i32 0, i32 4
%92 = load volatile i64, i64* %91
%93 = and i64 %92, 65535
%94 = icmp ne i64 %93, 16
br i1 %94, label %95, label %96
95: ; preds = %89
br label %89
96: ; preds = %89
%97 = load %struct.grcan_ctrl*, %struct.grcan_ctrl** %4
%98 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %97, i32 0, i32 1
%99 = load volatile i64, i64* %98
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %96
%102 = call i32 @fail(i32 1)
br label %103
103: ; preds = %101, %96
%104 = load %struct.grcan_irq*, %struct.grcan_irq** %5
%105 = getelementptr inbounds %struct.grcan_irq, %struct.grcan_irq* %104, i32 0, i32 3
%106 = load volatile i64, i64* %105
%107 = icmp ne i64 %106, 1344
br i1 %107, label %108, label %110
108: ; preds = %103
%109 = call i32 @fail(i32 2)
br label %110
110: ; preds = %108, %103
%111 = load %struct.grcan_irq*, %struct.grcan_irq** %5
%112 = getelementptr inbounds %struct.grcan_irq, %struct.grcan_irq* %111, i32 0, i32 5
store volatile i64 4294967295, i64* %112
store i32 1, i32* %14
store i32 2, i32* %15
%113 = load %struct.grcan_ctrl*, %struct.grcan_ctrl** %4
%114 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %113, i32 0, i32 2
store volatile i64 2, i64* %114
%115 = load i32, i32* %9
%116 = shl i32 %115, 24
%117 = load i32, i32* %10
%118 = shl i32 %117, 20
%119 = or i32 %116, %118
%120 = load i32, i32* %11
%121 = shl i32 %120, 16
%122 = or i32 %119, %121
%123 = load i32, i32* %12
%124 = shl i32 %123, 12
%125 = or i32 %122, %124
%126 = load i32, i32* %13
%127 = shl i32 %126, 8
%128 = or i32 %125, %127
%129 = load i32, i32* %14
%130 = shl i32 %129, 3
%131 = or i32 %128, %130
%132 = load i32, i32* %15
%133 = shl i32 %132, 1
%134 = or i32 %131, %133
%135 = sext i32 %134 to i64
%136 = load %struct.grcan_ctrl*, %struct.grcan_ctrl** %4
%137 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %136, i32 0, i32 0
store volatile i64 %135, i64* %137
%138 = load %struct.grcan_irq*, %struct.grcan_irq** %5
%139 = getelementptr inbounds %struct.grcan_irq, %struct.grcan_irq* %138, i32 0, i32 5
store volatile i64 4294967295, i64* %139
%140 = load %struct.grcan_ctrl*, %struct.grcan_ctrl** %4
%141 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %140, i32 0, i32 2
store volatile i64 1, i64* %141
%142 = load i64, i64* %8
%143 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%144 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %143, i32 0, i32 1
store volatile i64 %142, i64* %144
%145 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%146 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %145, i32 0, i32 2
store volatile i64 128, i64* %146
%147 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%148 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %147, i32 0, i32 5
store volatile i64 16, i64* %148
%149 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%150 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %149, i32 0, i32 0
store volatile i64 1, i64* %150
%151 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%152 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %151, i32 0, i32 3
store volatile i64 16, i64* %152
br label %153
153: ; preds = %159, %110
%154 = load %struct.grcan_tx*, %struct.grcan_tx** %6
%155 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %154, i32 0, i32 4
%156 = load volatile i64, i64* %155
%157 = and i64 %156, 65535
%158 = icmp ne i64 %157, 16
br i1 %158, label %159, label %160
159: ; preds = %153
br label %153
160: ; preds = %153
%161 = load %struct.grcan_ctrl*, %struct.grcan_ctrl** %4
%162 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %161, i32 0, i32 1
%163 = load volatile i64, i64* %162
%164 = icmp ne i64 %163, 0
br i1 %164, label %165, label %167
165: ; preds = %160
%166 = call i32 @fail(i32 3)
br label %167
167: ; preds = %165, %160
%168 = load %struct.grcan_irq*, %struct.grcan_irq** %5
%169 = getelementptr inbounds %struct.grcan_irq, %struct.grcan_irq* %168, i32 0, i32 3
%170 = load volatile i64, i64* %169
%171 = icmp ne i64 %170, 1344
br i1 %171, label %172, label %174
172: ; preds = %167
%173 = call i32 @fail(i32 4)
br label %174
174: ; preds = %172, %167
%175 = load %struct.grcan_irq*, %struct.grcan_irq** %5
%176 = getelementptr inbounds %struct.grcan_irq, %struct.grcan_irq* %175, i32 0, i32 5
store volatile i64 4294967295, i64* %176
%177 = load %struct.grcan_ctrl*, %struct.grcan_ctrl** %4
%178 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %177, i32 0, i32 2
store volatile i64 2, i64* %178
%179 = load i32, i32* %2
ret i32 %179
}

LLVM IR (-O2):
%struct.grcan_ctrl = type { i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.grcan_irq = type { i64, i64, i64, i64, i64, i64 }
%struct.grcan_tx = type { i64, i64, i64, i64, i64, i64 }
define i32 @grcan_test(i32 %0) {
%2 = alloca [512 x i64]
%3 = tail call i32 @report_device(i32 17027072)
%4 = sext i32 %0 to i64
%5 = inttoptr i64 %4 to %struct.grcan_ctrl*
%6 = add nsw i32 %0, 256
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to %struct.grcan_irq*
%9 = add nsw i32 %0, 512
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to %struct.grcan_tx*
%12 = bitcast [512 x i64]* %2 to i8*
%13 = ptrtoint [512 x i64]* %2 to i64
%14 = and i64 %13, 4294966272
%15 = add nuw nsw i64 %14, 1024
%16 = inttoptr i64 %15 to i32*
store volatile i32 -1858766403, i32* %16
%17 = getelementptr inbounds i32, i32* %16, i64 1
store volatile i32 -2147483648, i32* %17
%18 = getelementptr inbounds i32, i32* %16, i64 2
store volatile i32 16909060, i32* %18
%19 = getelementptr inbounds i32, i32* %16, i64 3
store volatile i32 84281096, i32* %19
%20 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %5, i64 0, i32 2
store volatile i64 2, i64* %20
%21 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %5, i64 0, i32 0
store volatile i64 2232322, i64* %21
%22 = getelementptr inbounds %struct.grcan_irq, %struct.grcan_irq* %8, i64 0, i32 5
store volatile i64 4294967295, i64* %22
store volatile i64 1, i64* %20
%23 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %11, i64 0, i32 1
store volatile i64 %15, i64* %23
%24 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %11, i64 0, i32 2
store volatile i64 128, i64* %24
%25 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %11, i64 0, i32 5
store volatile i64 16, i64* %25
%26 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %11, i64 0, i32 0
store volatile i64 1, i64* %26
%27 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %11, i64 0, i32 3
store volatile i64 16, i64* %27
%28 = getelementptr inbounds %struct.grcan_tx, %struct.grcan_tx* %11, i64 0, i32 4
br label %29
29: ; preds = %29, %1
%30 = load volatile i64, i64* %28
%31 = and i64 %30, 65535
%32 = icmp eq i64 %31, 16
br i1 %32, label %33, label %29
33: ; preds = %29
%34 = getelementptr inbounds %struct.grcan_ctrl, %struct.grcan_ctrl* %5, i64 0, i32 1
%35 = load volatile i64, i64* %34
%36 = icmp eq i64 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %33
%38 = call i32 @fail(i32 1)
br label %39
39: ; preds = %37, %33
%40 = getelementptr inbounds %struct.grcan_irq, %struct.grcan_irq* %8, i64 0, i32 3
%41 = load volatile i64, i64* %40
%42 = icmp eq i64 %41, 1344
br i1 %42, label %45, label %43
43: ; preds = %39
%44 = call i32 @fail(i32 2)
br label %45
45: ; preds = %43, %39
store volatile i64 4294967295, i64* %22
store volatile i64 2, i64* %20
store volatile i64 2232332, i64* %21
store volatile i64 4294967295, i64* %22
store volatile i64 1, i64* %20
store volatile i64 %15, i64* %23
store volatile i64 128, i64* %24
store volatile i64 16, i64* %25
store volatile i64 1, i64* %26
store volatile i64 16, i64* %27
br label %46
46: ; preds = %46, %45
%47 = load volatile i64, i64* %28
%48 = and i64 %47, 65535
%49 = icmp eq i64 %48, 16
br i1 %49, label %50, label %46
50: ; preds = %46
%51 = load volatile i64, i64* %34
%52 = icmp eq i64 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = call i32 @fail(i32 3)
br label %55
55: ; preds = %53, %50
%56 = load volatile i64, i64* %40
%57 = icmp eq i64 %56, 1344
br i1 %57, label %60, label %58
58: ; preds = %55
%59 = call i32 @fail(i32 4)
br label %60
60: ; preds = %58, %55
store volatile i64 4294967295, i64* %22
store volatile i64 2, i64* %20
ret i32 undef
}