#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);
int /*<<< orphan*/ report_subtest(int);
grhcan_test(int paddr) {
  report_device(0x01034000);
  struct grhcan_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 grhcan_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 grhcan_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 grhcan_ctrl *lctrl = (struct grhcan_ctrl *)(paddr);
  struct grhcan_irq *lirq = (struct grhcan_irq *)(paddr + 0x100);
  struct grhcan_tx *ltx0 = (struct grhcan_tx *)(paddr + 0x200);
  volatile long int memory[512];
  volatile int i = 0;
  long int memorytxbase;
  memorytxbase = (long int)&memory[0];
  memorytxbase = memorytxbase & 0xFFFFFC00;
  memorytxbase = memorytxbase + 0x400;
  int SCALER = 0;
  int PS1 = 3;
  int PS2 = 3;
  int RSJ = 1;
  int BPR = 0;
  int SELECTION = 0;
  int ENABLE = 0x1;
  report_subtest(0x1);
  volatile int *memorytx;
  memorytx = (int *)memorytxbase;
  *memorytx = 0x913579BD;
  memorytx++;
  *memorytx = 0x80000000;
  memorytx++;
  *memorytx = 0x01020304;
  memorytx++;
  *memorytx = 0x05060708;
  memorytx++;
  report_subtest(0x2);
  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;
  report_subtest(0x3);
  ltx0->addr = memorytxbase;
  ltx0->size = 0x00000080;
  ltx0->wr = 0x00000000;
  ltx0->rd = 0x00000000;
  ltx0->irq = 0x00000010;
  ltx0->ctrl = 0x00000001;
  ltx0->wr = 0x00000010;
  while ((ltx0->rd & 0xFFFF) != 0x0010)
    ;
  while (i < 20)
    i++;
  i = 0;
  if (lctrl->stat != 0x00000000)
    fail(1);
  if (lirq->pir != 0x00000540)
    fail(2);
  report_subtest(0x4);
  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->wr = 0x00000000;
  ltx0->rd = 0x00000000;
  ltx0->irq = 0x00000010;
  ltx0->ctrl = 0x00000001;
  ltx0->wr = 0x00000010;
  while ((ltx0->rd & 0xFFFF) != 0x0010)
    ;
  while (i < 20)
    i++;
  if (lctrl->stat != 0x00000000)
    fail(3);
  if (lirq->pir != 0x00000540)
    fail(4);
  lirq->picr = 0xFFFFFFFF;
  lctrl->ctrl = 0x00000002;
}


x86 assembly (clang, -O0):
<grhcan_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x1034000,%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)
movl   $0x0,-0x1024(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1030(%rbp)
movabs $0xfffffc00,%rax
and    -0x1030(%rbp),%rax
mov    %rax,-0x1030(%rbp)
mov    -0x1030(%rbp),%rax
add    $0x400,%rax
mov    %rax,-0x1030(%rbp)
movl   $0x0,-0x1034(%rbp)
movl   $0x3,-0x1038(%rbp)
movl   $0x3,-0x103c(%rbp)
movl   $0x1,-0x1040(%rbp)
movl   $0x0,-0x1044(%rbp)
movl   $0x0,-0x1048(%rbp)
movl   $0x1,-0x104c(%rbp)
mov    $0x1,%edi
call   1040 <report_subtest@plt>
mov    -0x1030(%rbp),%rax
mov    %rax,-0x1058(%rbp)
mov    -0x1058(%rbp),%rax
movl   $0x913579bd,(%rax)
mov    -0x1058(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x1058(%rbp)
mov    -0x1058(%rbp),%rax
movl   $0x80000000,(%rax)
mov    -0x1058(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x1058(%rbp)
mov    -0x1058(%rbp),%rax
movl   $0x1020304,(%rax)
mov    -0x1058(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x1058(%rbp)
mov    -0x1058(%rbp),%rax
movl   $0x5060708,(%rax)
mov    -0x1058(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x1058(%rbp)
mov    $0x2,%edi
call   1040 <report_subtest@plt>
mov    -0x10(%rbp),%rax
movq   $0x2,0x10(%rax)
mov    -0x1034(%rbp),%eax
shl    $0x18,%eax
mov    -0x1038(%rbp),%ecx
shl    $0x14,%ecx
or     %ecx,%eax
mov    -0x103c(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x1040(%rbp),%ecx
shl    $0xc,%ecx
or     %ecx,%eax
mov    -0x1044(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x1048(%rbp),%ecx
shl    $0x3,%ecx
or     %ecx,%eax
mov    -0x104c(%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    $0x3,%edi
call   1040 <report_subtest@plt>
mov    -0x1030(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
movq   $0x80,0x10(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,0x18(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,0x20(%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     138b <grhcan_test+0x25b>
jmp    136e <grhcan_test+0x23e>
jmp    1390 <grhcan_test+0x260>
mov    -0x1024(%rbp),%eax
cmp    $0x14,%eax
jge    13b3 <grhcan_test+0x283>
mov    -0x1024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1024(%rbp)
jmp    1390 <grhcan_test+0x260>
movl   $0x0,-0x1024(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
cmp    $0x0,%rax
je     13d9 <grhcan_test+0x2a9>
mov    $0x1,%edi
call   1050 <fail@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmp    $0x540,%rax
je     13f7 <grhcan_test+0x2c7>
mov    $0x2,%edi
call   1050 <fail@plt>
mov    $0x4,%edi
call   1040 <report_subtest@plt>
mov    -0x18(%rbp),%rax
mov    $0xffffffff,%ecx
mov    %rcx,0x28(%rax)
movl   $0x1,-0x1048(%rbp)
movl   $0x2,-0x104c(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x2,0x10(%rax)
mov    -0x1034(%rbp),%eax
shl    $0x18,%eax
mov    -0x1038(%rbp),%ecx
shl    $0x14,%ecx
or     %ecx,%eax
mov    -0x103c(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x1040(%rbp),%ecx
shl    $0xc,%ecx
or     %ecx,%eax
mov    -0x1044(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x1048(%rbp),%ecx
shl    $0x3,%ecx
or     %ecx,%eax
mov    -0x104c(%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    -0x1030(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x20(%rbp),%rax
movq   $0x80,0x10(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,0x18(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,0x20(%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     150f <grhcan_test+0x3df>
jmp    14f2 <grhcan_test+0x3c2>
jmp    1514 <grhcan_test+0x3e4>
mov    -0x1024(%rbp),%eax
cmp    $0x14,%eax
jge    1537 <grhcan_test+0x407>
mov    -0x1024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1024(%rbp)
jmp    1514 <grhcan_test+0x3e4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
cmp    $0x0,%rax
je     1553 <grhcan_test+0x423>
mov    $0x3,%edi
call   1050 <fail@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmp    $0x540,%rax
je     1571 <grhcan_test+0x441>
mov    $0x4,%edi
call   1050 <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    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grhcan_test>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %edi,%ebx
mov    $0xffffffff,%r14d
mov    $0x1034000,%edi
call   1030 <report_device@plt>
movslq %ebx,%rbx
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%r12
and    $0xfffffc00,%r12d
lea    0x400(%r12),%r15
mov    $0x1,%edi
call   1040 <report_subtest@plt>
movl   $0x913579bd,0x400(%r12)
movl   $0x80000000,0x404(%r12)
movl   $0x1020304,0x408(%r12)
movl   $0x5060708,0x40c(%r12)
mov    $0x2,%edi
call   1040 <report_subtest@plt>
movq   $0x2,0x10(%rbx)
movq   $0x331002,(%rbx)
mov    %r14,0x128(%rbx)
movq   $0x1,0x10(%rbx)
mov    $0x3,%edi
call   1040 <report_subtest@plt>
mov    %r15,0x208(%rbx)
movq   $0x80,0x210(%rbx)
movq   $0x0,0x218(%rbx)
movq   $0x0,0x220(%rbx)
movq   $0x10,0x228(%rbx)
movq   $0x1,0x200(%rbx)
movq   $0x10,0x218(%rbx)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x220(%rbx),%rax
cmp    $0x10,%ax
jne    1230 <grhcan_test+0x100>
mov    0xc(%rsp),%eax
cmp    $0x13,%eax
jg     125e <grhcan_test+0x12e>
cs nopw 0x0(%rax,%rax,1)
addl   $0x1,0xc(%rsp)
mov    0xc(%rsp),%eax
cmp    $0x14,%eax
jl     1250 <grhcan_test+0x120>
movl   $0x0,0xc(%rsp)
cmpq   $0x0,0x8(%rbx)
je     1277 <grhcan_test+0x147>
mov    $0x1,%edi
call   1050 <fail@plt>
mov    0x118(%rbx),%rax
cmp    $0x540,%rax
je     1290 <grhcan_test+0x160>
mov    $0x2,%edi
call   1050 <fail@plt>
mov    $0x4,%edi
call   1040 <report_subtest@plt>
mov    %r14,0x128(%rbx)
movq   $0x2,0x10(%rbx)
movq   $0x33100c,(%rbx)
mov    %r14,0x128(%rbx)
movq   $0x1,0x10(%rbx)
mov    %r15,0x208(%rbx)
movq   $0x80,0x210(%rbx)
movq   $0x0,0x218(%rbx)
movq   $0x0,0x220(%rbx)
movq   $0x10,0x228(%rbx)
movq   $0x1,0x200(%rbx)
movq   $0x10,0x218(%rbx)
nopl   0x0(%rax,%rax,1)
mov    0x220(%rbx),%rax
cmp    $0x10,%ax
jne    1310 <grhcan_test+0x1e0>
mov    0xc(%rsp),%eax
cmp    $0x13,%eax
jg     133e <grhcan_test+0x20e>
cs nopw 0x0(%rax,%rax,1)
addl   $0x1,0xc(%rsp)
mov    0xc(%rsp),%eax
cmp    $0x14,%eax
jl     1330 <grhcan_test+0x200>
cmpq   $0x0,0x8(%rbx)
je     134f <grhcan_test+0x21f>
mov    $0x3,%edi
call   1050 <fail@plt>
mov    0x118(%rbx),%rax
cmp    $0x540,%rax
je     1368 <grhcan_test+0x238>
mov    $0x4,%edi
call   1050 <fail@plt>
mov    %r14,0x128(%rbx)
movq   $0x2,0x10(%rbx)
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.grhcan_ctrl = type { i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.grhcan_irq = type { i64, i64, i64, i64, i64, i64 }
%struct.grhcan_tx = type { i64, i64, i64, i64, i64, i64 }
define i32 @grhcan_test(i32 %0) {
%2 = alloca [512 x i64]
%3 = alloca i32
%4 = tail call i32 @report_device(i32 16990208)
%5 = sext i32 %0 to i64
%6 = inttoptr i64 %5 to %struct.grhcan_ctrl*
%7 = add nsw i32 %0, 256
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to %struct.grhcan_irq*
%10 = add nsw i32 %0, 512
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to %struct.grhcan_tx*
%13 = bitcast [512 x i64]* %2 to i8*
%14 = bitcast i32* %3 to i8*
store volatile i32 0, i32* %3
%15 = ptrtoint [512 x i64]* %2 to i64
%16 = and i64 %15, 4294966272
%17 = add nuw nsw i64 %16, 1024
%18 = call i32 @report_subtest(i32 1)
%19 = inttoptr i64 %17 to i32*
store volatile i32 -1858766403, i32* %19
%20 = getelementptr inbounds i32, i32* %19, i64 1
store volatile i32 -2147483648, i32* %20
%21 = getelementptr inbounds i32, i32* %19, i64 2
store volatile i32 16909060, i32* %21
%22 = getelementptr inbounds i32, i32* %19, i64 3
store volatile i32 84281096, i32* %22
%23 = call i32 @report_subtest(i32 2)
%24 = getelementptr inbounds %struct.grhcan_ctrl, %struct.grhcan_ctrl* %6, i64 0, i32 2
store volatile i64 2, i64* %24
%25 = getelementptr inbounds %struct.grhcan_ctrl, %struct.grhcan_ctrl* %6, i64 0, i32 0
store volatile i64 3346434, i64* %25
%26 = getelementptr inbounds %struct.grhcan_irq, %struct.grhcan_irq* %9, i64 0, i32 5
store volatile i64 4294967295, i64* %26
store volatile i64 1, i64* %24
%27 = call i32 @report_subtest(i32 3)
%28 = getelementptr inbounds %struct.grhcan_tx, %struct.grhcan_tx* %12, i64 0, i32 1
store volatile i64 %17, i64* %28
%29 = getelementptr inbounds %struct.grhcan_tx, %struct.grhcan_tx* %12, i64 0, i32 2
store volatile i64 128, i64* %29
%30 = getelementptr inbounds %struct.grhcan_tx, %struct.grhcan_tx* %12, i64 0, i32 3
store volatile i64 0, i64* %30
%31 = getelementptr inbounds %struct.grhcan_tx, %struct.grhcan_tx* %12, i64 0, i32 4
store volatile i64 0, i64* %31
%32 = getelementptr inbounds %struct.grhcan_tx, %struct.grhcan_tx* %12, i64 0, i32 5
store volatile i64 16, i64* %32
%33 = getelementptr inbounds %struct.grhcan_tx, %struct.grhcan_tx* %12, i64 0, i32 0
store volatile i64 1, i64* %33
store volatile i64 16, i64* %30
br label %34
34: ; preds = %34, %1
%35 = load volatile i64, i64* %31
%36 = and i64 %35, 65535
%37 = icmp eq i64 %36, 16
br i1 %37, label %38, label %34
38: ; preds = %34
%39 = load volatile i32, i32* %3
%40 = icmp slt i32 %39, 20
br i1 %40, label %41, label %46
41: ; preds = %38, %41
%42 = load volatile i32, i32* %3
%43 = add nsw i32 %42, 1
store volatile i32 %43, i32* %3
%44 = load volatile i32, i32* %3
%45 = icmp slt i32 %44, 20
br i1 %45, label %41, label %46
46: ; preds = %41, %38
store volatile i32 0, i32* %3
%47 = getelementptr inbounds %struct.grhcan_ctrl, %struct.grhcan_ctrl* %6, i64 0, i32 1
%48 = load volatile i64, i64* %47
%49 = icmp eq i64 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %46
%51 = call i32 @fail(i32 1)
br label %52
52: ; preds = %50, %46
%53 = getelementptr inbounds %struct.grhcan_irq, %struct.grhcan_irq* %9, i64 0, i32 3
%54 = load volatile i64, i64* %53
%55 = icmp eq i64 %54, 1344
br i1 %55, label %58, label %56
56: ; preds = %52
%57 = call i32 @fail(i32 2)
br label %58
58: ; preds = %56, %52
%59 = call i32 @report_subtest(i32 4)
store volatile i64 4294967295, i64* %26
store volatile i64 2, i64* %24
store volatile i64 3346444, i64* %25
store volatile i64 4294967295, i64* %26
store volatile i64 1, i64* %24
store volatile i64 %17, i64* %28
store volatile i64 128, i64* %29
store volatile i64 0, i64* %30
store volatile i64 0, i64* %31
store volatile i64 16, i64* %32
store volatile i64 1, i64* %33
store volatile i64 16, i64* %30
br label %60
60: ; preds = %60, %58
%61 = load volatile i64, i64* %31
%62 = and i64 %61, 65535
%63 = icmp eq i64 %62, 16
br i1 %63, label %64, label %60
64: ; preds = %60
%65 = load volatile i32, i32* %3
%66 = icmp slt i32 %65, 20
br i1 %66, label %67, label %72
67: ; preds = %64, %67
%68 = load volatile i32, i32* %3
%69 = add nsw i32 %68, 1
store volatile i32 %69, i32* %3
%70 = load volatile i32, i32* %3
%71 = icmp slt i32 %70, 20
br i1 %71, label %67, label %72
72: ; preds = %67, %64
%73 = load volatile i64, i64* %47
%74 = icmp eq i64 %73, 0
br i1 %74, label %77, label %75
75: ; preds = %72
%76 = call i32 @fail(i32 3)
br label %77
77: ; preds = %75, %72
%78 = load volatile i64, i64* %53
%79 = icmp eq i64 %78, 1344
br i1 %79, label %82, label %80
80: ; preds = %77
%81 = call i32 @fail(i32 4)
br label %82
82: ; preds = %80, %77
store volatile i64 4294967295, i64* %26
store volatile i64 2, i64* %24
ret i32 undef
}