#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, char, int,
                           ...);
int main() {
  int i;
  int off;
  FILE *f;
  f = fopen("bitfield.struct.inc", "w");
  for (off = 0; off < 8; off++) {
    for (i = 1; i <= 64; i++) {
      int nbits;
      if (i <= 16)
        nbits = 16;
      else if (i <= 32)
        nbits = 32;
      else
        nbits = 64;
      fprintf(f,
              "struct off%di%d { long : %d; int%d_t  data : %d; } "
              "__attribute__ ((packed));\n",
              off, i, off, nbits, i);
      fprintf(f,
              "struct off%du%d { long : %d; uint%d_t data : %d; } "
              "__attribute__ ((packed));\n",
              off, i, off, nbits, i);
    }
  }
  fclose(f);
  int is_signed;
  f = fopen("bitfield.function.get.inc", "w");
  for (i = 1; i <= 64; i++) {
    for (off = 0; off < 8; off++) {
      for (is_signed = 0; is_signed < 2; is_signed++) {
        fprintf(f, "case %d: return ((struct off%d%c%d *) data)->data;\n",
                i * 16 + off * 2 + is_signed, off, is_signed ? 'i' : 'u', i);
      }
    }
  }
  f = fopen("bitfield.function.set.inc", "w");
  for (i = 1; i <= 64; i++) {
    for (off = 0; off < 8; off++) {
      for (is_signed = 0; is_signed < 2; is_signed++) {
        fprintf(f,
                "case %d: { int64_t ov = ((struct off%d%c%d *) data)->data; "
                "((struct off%d%c%d *) data)->data = value; return ov; }\n",
                i * 16 + off * 2 + is_signed, off, is_signed ? 'i' : 'u', i,
                off, is_signed ? 'i' : 'u', i);
      }
    }
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1229 <main+0xf9>
movl   $0x1,-0x8(%rbp)
cmpl   $0x40,-0x8(%rbp)
jg     1216 <main+0xe6>
cmpl   $0x10,-0x8(%rbp)
jg     118e <main+0x5e>
movl   $0x10,-0x1c(%rbp)
jmp    11b0 <main+0x80>
cmpl   $0x20,-0x8(%rbp)
jg     11a4 <main+0x74>
movl   $0x20,-0x1c(%rbp)
jmp    11ab <main+0x7b>
movl   $0x40,-0x1c(%rbp)
jmp    11b0 <main+0x80>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
mov    %al,%r8b
mov    -0x1c(%rbp),%r9d
mov    -0x8(%rbp),%eax
lea    0xe48(%rip),%rsi
movsbl %r8b,%r8d
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
mov    %al,%r8b
mov    -0x1c(%rbp),%r9d
mov    -0x8(%rbp),%eax
lea    0xe6a(%rip),%rsi
movsbl %r8b,%r8d
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <main+0x3e>
jmp    121b <main+0xeb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <main+0x2d>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe79(%rip),%rdi
lea    0xdd4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x40,-0x8(%rbp)
jg     12f3 <main+0x1c3>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    12e0 <main+0x1b0>
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jge    12cd <main+0x19d>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
shl    $0x4,%edx
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
add    %eax,%edx
add    -0x20(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    $0x75,%eax
mov    $0x69,%esi
cmp    $0x0,%r8d
cmovne %esi,%eax
mov    -0x8(%rbp),%r9d
lea    0xe18(%rip),%rsi
movsbl %al,%r8d
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1272 <main+0x142>
jmp    12d2 <main+0x1a2>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1261 <main+0x131>
jmp    12e5 <main+0x1b5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1250 <main+0x120>
lea    0xe06(%rip),%rdi
lea    0xd13(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x40,-0x8(%rbp)
jg     13e0 <main+0x2b0>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    13cd <main+0x29d>
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jge    13ba <main+0x28a>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
shl    $0x4,%edx
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
add    %eax,%edx
add    -0x20(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    $0x75,%eax
mov    $0x69,%esi
cmp    $0x0,%r8d
cmovne %esi,%eax
mov    %al,%r8b
mov    -0x8(%rbp),%r9d
mov    -0xc(%rbp),%r11d
mov    -0x20(%rbp),%esi
mov    $0x75,%r10d
mov    $0x69,%eax
cmp    $0x0,%esi
cmovne %eax,%r10d
mov    -0x8(%rbp),%eax
lea    0xd86(%rip),%rsi
movsbl %r8b,%r8d
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1333 <main+0x203>
jmp    13bf <main+0x28f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1322 <main+0x1f2>
jmp    13d2 <main+0x2a2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1311 <main+0x1e1>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r12
mov    $0x10,%eax
lea    0xeb9(%rip),%r15
xor    %r13d,%r13d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebp,%ebp
cmp    $0x21,%ebx
setae  %bpl
shl    $0x5,%ebp
add    $0x20,%ebp
cmp    $0x11,%ebx
cmovb  %eax,%ebp
sub    $0x8,%rsp
movsbl %r13b,%r14d
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
push   %rbx
call   1040 <fprintf@plt>
add    $0x8,%rsp
mov    %r12,%rdi
lea    0xeb0(%rip),%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
push   %rbx
call   1040 <fprintf@plt>
mov    $0x10,%eax
add    $0x10,%rsp
add    $0x1,%ebx
cmp    $0x41,%ebx
jne    1170 <main+0x40>
add    $0x1,%r13d
cmp    $0x8,%r13d
jne    1160 <main+0x30>
mov    %r12,%rdi
call   1030 <fclose@plt>
lea    0xebd(%rip),%rdi
lea    0xe18(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    $0x1,%ebp
mov    $0x1f,%ebx
lea    0xeb7(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0xf(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %ecx,%ecx
mov    $0x75,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0xe(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %ecx,%ecx
mov    $0x69,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0xd(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%ecx
mov    $0x75,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0xc(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%ecx
mov    $0x69,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0xb(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%ecx
mov    $0x75,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0xa(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%ecx
mov    $0x69,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x9(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x3,%ecx
mov    $0x75,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x8(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x3,%ecx
mov    $0x69,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x7(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%ecx
mov    $0x75,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x6(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%ecx
mov    $0x69,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x5(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x5,%ecx
mov    $0x75,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x4(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x5,%ecx
mov    $0x69,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x3(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x6,%ecx
mov    $0x75,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x2(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x6,%ecx
mov    $0x69,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    -0x1(%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x7,%ecx
mov    $0x75,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x7,%ecx
mov    $0x69,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%ebp
add    $0x10,%ebx
cmp    $0x41f,%ebx
jne    1220 <main+0xf0>
lea    0xcee(%rip),%rdi
lea    0xbfb(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    $0x1,%ebx
mov    $0x1f,%r15d
lea    0xce7(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0xf(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
xor    %ecx,%ecx
mov    $0x75,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x75
push   $0x0
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0xe(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
xor    %ecx,%ecx
mov    $0x69,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x69
push   $0x0
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0xd(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x1,%ecx
mov    $0x75,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x75
push   $0x1
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0xc(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x1,%ecx
mov    $0x69,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x69
push   $0x1
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0xb(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x2,%ecx
mov    $0x75,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x75
push   $0x2
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0xa(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x2,%ecx
mov    $0x69,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x69
push   $0x2
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0x9(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x3,%ecx
mov    $0x75,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x75
push   $0x3
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0x8(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x3,%ecx
mov    $0x69,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x69
push   $0x3
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0x7(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x4,%ecx
mov    $0x75,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x75
push   $0x4
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0x6(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x4,%ecx
mov    $0x69,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x69
push   $0x4
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0x5(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x5,%ecx
mov    $0x75,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x75
push   $0x5
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0x4(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x5,%ecx
mov    $0x69,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x69
push   $0x5
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0x3(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x6,%ecx
mov    $0x75,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x75
push   $0x6
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0x2(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x6,%ecx
mov    $0x69,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x69
push   $0x6
call   1040 <fprintf@plt>
add    $0x20,%rsp
lea    -0x1(%r15),%edx
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x7,%ecx
mov    $0x75,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x75
push   $0x7
call   1040 <fprintf@plt>
add    $0x18,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    $0x7,%ecx
mov    $0x69,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
push   %rbx
push   $0x69
push   $0x7
call   1040 <fprintf@plt>
add    $0x20,%rsp
add    $0x1,%ebx
add    $0x10,%r15d
cmp    $0x41f,%r15d
jne    1440 <main+0x310>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"bitfield.struct.inc\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [78 x i8] c"struct off%di%d { long : %d; int%d_t data : %d; } __attribute__ ((packed));\0A\00"
@.str.3 = [78 x i8] c"struct off%du%d { long : %d; uint%d_t data : %d; } __attribute__ ((packed));\0A\00"
@.str.4 = [26 x i8] c"bitfield.function.get.inc\00"
@.str.5 = [52 x i8] c"case %d: return ((struct off%d%c%d *) data)->data;\0A\00"
@.str.6 = [26 x i8] c"bitfield.function.set.inc\00"
@.str.7 = [116 x i8] c"case %d: { int64_t ov = ((struct off%d%c%d *) data)->data; ((struct off%d%c%d *) data)->data = value; return ov; }\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
store i32 0, i32* %3
br label %8
8: ; preds = %46, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %49
11: ; preds = %8
store i32 1, i32* %2
br label %12
12: ; preds = %42, %11
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 64
br i1 %14, label %15, label %45
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp sle i32 %16, 16
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 16, i32* %5
br label %25
19: ; preds = %15
%20 = load i32, i32* %2
%21 = icmp sle i32 %20, 32
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 32, i32* %5
br label %24
23: ; preds = %19
store i32 64, i32* %5
br label %24
24: ; preds = %23, %22
br label %25
25: ; preds = %24, %18
%26 = load i32*, i32** %4
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = trunc i32 %29 to i8
%31 = load i32, i32* %5
%32 = load i32, i32* %2
%33 = call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28, i8 signext %30, i32 %31, i32 %32)
%34 = load i32*, i32** %4
%35 = load i32, i32* %3
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = trunc i32 %37 to i8
%39 = load i32, i32* %5
%40 = load i32, i32* %2
%41 = call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %36, i8 signext %38, i32 %39, i32 %40)
br label %42
42: ; preds = %25
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %12
45: ; preds = %12
br label %46
46: ; preds = %45
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %8
49: ; preds = %8
%50 = load i32*, i32** %4
%51 = call i32 @fclose(i32* %50)
%52 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %52, i32** %4
store i32 1, i32* %2
br label %53
53: ; preds = %89, %49
%54 = load i32, i32* %2
%55 = icmp sle i32 %54, 64
br i1 %55, label %56, label %92
56: ; preds = %53
store i32 0, i32* %3
br label %57
57: ; preds = %85, %56
%58 = load i32, i32* %3
%59 = icmp slt i32 %58, 8
br i1 %59, label %60, label %88
60: ; preds = %57
store i32 0, i32* %6
br label %61
61: ; preds = %81, %60
%62 = load i32, i32* %6
%63 = icmp slt i32 %62, 2
br i1 %63, label %64, label %84
64: ; preds = %61
%65 = load i32*, i32** %4
%66 = load i32, i32* %2
%67 = mul nsw i32 %66, 16
%68 = load i32, i32* %3
%69 = mul nsw i32 %68, 2
%70 = add nsw i32 %67, %69
%71 = load i32, i32* %6
%72 = add nsw i32 %70, %71
%73 = load i32, i32* %3
%74 = load i32, i32* %6
%75 = icmp ne i32 %74, 0
%76 = zext i1 %75 to i64
%77 = select i1 %75, i32 105, i32 117
%78 = trunc i32 %77 to i8
%79 = load i32, i32* %2
%80 = call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %72, i32 %73, i8 signext %78, i32 %79)
br label %81
81: ; preds = %64
%82 = load i32, i32* %6
%83 = add nsw i32 %82, 1
store i32 %83, i32* %6
br label %61
84: ; preds = %61
br label %85
85: ; preds = %84
%86 = load i32, i32* %3
%87 = add nsw i32 %86, 1
store i32 %87, i32* %3
br label %57
88: ; preds = %57
br label %89
89: ; preds = %88
%90 = load i32, i32* %2
%91 = add nsw i32 %90, 1
store i32 %91, i32* %2
br label %53
92: ; preds = %53
%93 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %93, i32** %4
store i32 1, i32* %2
br label %94
94: ; preds = %136, %92
%95 = load i32, i32* %2
%96 = icmp sle i32 %95, 64
br i1 %96, label %97, label %139
97: ; preds = %94
store i32 0, i32* %3
br label %98
98: ; preds = %132, %97
%99 = load i32, i32* %3
%100 = icmp slt i32 %99, 8
br i1 %100, label %101, label %135
101: ; preds = %98
store i32 0, i32* %6
br label %102
102: ; preds = %128, %101
%103 = load i32, i32* %6
%104 = icmp slt i32 %103, 2
br i1 %104, label %105, label %131
105: ; preds = %102
%106 = load i32*, i32** %4
%107 = load i32, i32* %2
%108 = mul nsw i32 %107, 16
%109 = load i32, i32* %3
%110 = mul nsw i32 %109, 2
%111 = add nsw i32 %108, %110
%112 = load i32, i32* %6
%113 = add nsw i32 %111, %112
%114 = load i32, i32* %3
%115 = load i32, i32* %6
%116 = icmp ne i32 %115, 0
%117 = zext i1 %116 to i64
%118 = select i1 %116, i32 105, i32 117
%119 = trunc i32 %118 to i8
%120 = load i32, i32* %2
%121 = load i32, i32* %3
%122 = load i32, i32* %6
%123 = icmp ne i32 %122, 0
%124 = zext i1 %123 to i64
%125 = select i1 %123, i32 105, i32 117
%126 = load i32, i32* %2
%127 = call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %106, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %113, i32 %114, i8 signext %119, i32 %120, i32 %121, i32 %125, i32 %126)
br label %128
128: ; preds = %105
%129 = load i32, i32* %6
%130 = add nsw i32 %129, 1
store i32 %130, i32* %6
br label %102
131: ; preds = %102
br label %132
132: ; preds = %131
%133 = load i32, i32* %3
%134 = add nsw i32 %133, 1
store i32 %134, i32* %3
br label %98
135: ; preds = %98
br label %136
136: ; preds = %135
%137 = load i32, i32* %2
%138 = add nsw i32 %137, 1
store i32 %138, i32* %2
br label %94
139: ; preds = %94
%140 = load i32*, i32** %4
%141 = call i32 @fclose(i32* %140)
%142 = load i32, i32* %1
ret i32 %142
}

LLVM IR (-O2):
@.str = [20 x i8] c"bitfield.struct.inc\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [78 x i8] c"struct off%di%d { long : %d; int%d_t data : %d; } __attribute__ ((packed));\0A\00"
@.str.3 = [78 x i8] c"struct off%du%d { long : %d; uint%d_t data : %d; } __attribute__ ((packed));\0A\00"
@.str.4 = [26 x i8] c"bitfield.function.get.inc\00"
@.str.5 = [52 x i8] c"case %d: return ((struct off%d%c%d *) data)->data;\0A\00"
@.str.6 = [26 x i8] c"bitfield.function.set.inc\00"
@.str.7 = [116 x i8] c"case %d: { int64_t ov = ((struct off%d%c%d *) data)->data; ((struct off%d%c%d *) data)->data = value; return ov; }\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %2
2: ; preds = %0, %15
%3 = phi i32 [ 0, %0 ], [ %16, %15 ]
%4 = trunc i32 %3 to i8
br label %5
5: ; preds = %2, %5
%6 = phi i32 [ 1, %2 ], [ %13, %5 ]
%7 = icmp ugt i32 %6, 32
%8 = select i1 %7, i32 64, i32 32
%9 = icmp ugt i32 %6, 16
%10 = select i1 %9, i32 %8, i32 16
%11 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 %6, i8 signext %4, i32 %10, i32 %6)
%12 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0), i32 %3, i32 %6, i8 signext %4, i32 %10, i32 %6)
%13 = add nuw nsw i32 %6, 1
%14 = icmp eq i32 %13, 65
br i1 %14, label %15, label %5
15: ; preds = %5
%16 = add nuw nsw i32 %3, 1
%17 = icmp eq i32 %16, 8
br i1 %17, label %18, label %2
18: ; preds = %15
%19 = tail call i32 @fclose(i32* %1)
%20 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %18, %21
%22 = phi i32 [ 1, %18 ], [ %55, %21 ]
%23 = shl nsw i32 %22, 4
%24 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 0, i8 signext 117, i32 %22)
%25 = or i32 %23, 1
%26 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %25, i32 0, i8 signext 105, i32 %22)
%27 = or i32 %23, 2
%28 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %27, i32 1, i8 signext 117, i32 %22)
%29 = or i32 %23, 3
%30 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %29, i32 1, i8 signext 105, i32 %22)
%31 = or i32 %23, 4
%32 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %31, i32 2, i8 signext 117, i32 %22)
%33 = or i32 %23, 5
%34 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %33, i32 2, i8 signext 105, i32 %22)
%35 = or i32 %23, 6
%36 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %35, i32 3, i8 signext 117, i32 %22)
%37 = or i32 %23, 7
%38 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %37, i32 3, i8 signext 105, i32 %22)
%39 = or i32 %23, 8
%40 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %39, i32 4, i8 signext 117, i32 %22)
%41 = or i32 %23, 9
%42 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %41, i32 4, i8 signext 105, i32 %22)
%43 = or i32 %23, 10
%44 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %43, i32 5, i8 signext 117, i32 %22)
%45 = or i32 %23, 11
%46 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %45, i32 5, i8 signext 105, i32 %22)
%47 = or i32 %23, 12
%48 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %47, i32 6, i8 signext 117, i32 %22)
%49 = or i32 %23, 13
%50 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %49, i32 6, i8 signext 105, i32 %22)
%51 = or i32 %23, 14
%52 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %51, i32 7, i8 signext 117, i32 %22)
%53 = or i32 %23, 15
%54 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 %53, i32 7, i8 signext 105, i32 %22)
%55 = add nuw nsw i32 %22, 1
%56 = icmp eq i32 %55, 65
br i1 %56, label %57, label %21
57: ; preds = %21
%58 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %59
59: ; preds = %57, %59
%60 = phi i32 [ 1, %57 ], [ %93, %59 ]
%61 = shl nsw i32 %60, 4
%62 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %61, i32 0, i8 signext 117, i32 %60, i32 0, i32 117, i32 %60)
%63 = or i32 %61, 1
%64 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %63, i32 0, i8 signext 105, i32 %60, i32 0, i32 105, i32 %60)
%65 = or i32 %61, 2
%66 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %65, i32 1, i8 signext 117, i32 %60, i32 1, i32 117, i32 %60)
%67 = or i32 %61, 3
%68 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %67, i32 1, i8 signext 105, i32 %60, i32 1, i32 105, i32 %60)
%69 = or i32 %61, 4
%70 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %69, i32 2, i8 signext 117, i32 %60, i32 2, i32 117, i32 %60)
%71 = or i32 %61, 5
%72 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %71, i32 2, i8 signext 105, i32 %60, i32 2, i32 105, i32 %60)
%73 = or i32 %61, 6
%74 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %73, i32 3, i8 signext 117, i32 %60, i32 3, i32 117, i32 %60)
%75 = or i32 %61, 7
%76 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %75, i32 3, i8 signext 105, i32 %60, i32 3, i32 105, i32 %60)
%77 = or i32 %61, 8
%78 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %77, i32 4, i8 signext 117, i32 %60, i32 4, i32 117, i32 %60)
%79 = or i32 %61, 9
%80 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %79, i32 4, i8 signext 105, i32 %60, i32 4, i32 105, i32 %60)
%81 = or i32 %61, 10
%82 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %81, i32 5, i8 signext 117, i32 %60, i32 5, i32 117, i32 %60)
%83 = or i32 %61, 11
%84 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %83, i32 5, i8 signext 105, i32 %60, i32 5, i32 105, i32 %60)
%85 = or i32 %61, 12
%86 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %85, i32 6, i8 signext 117, i32 %60, i32 6, i32 117, i32 %60)
%87 = or i32 %61, 13
%88 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %87, i32 6, i8 signext 105, i32 %60, i32 6, i32 105, i32 %60)
%89 = or i32 %61, 14
%90 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %89, i32 7, i8 signext 117, i32 %60, i32 7, i32 117, i32 %60)
%91 = or i32 %61, 15
%92 = tail call i32 (i32*, i8*, i32, i32, i8, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.7, i64 0, i64 0), i32 %91, i32 7, i8 signext 105, i32 %60, i32 7, i32 105, i32 %60)
%93 = add nuw nsw i32 %60, 1
%94 = icmp eq i32 %93, 65
br i1 %94, label %95, label %59
95: ; preds = %59
%96 = tail call i32 @fclose(i32* %58)
ret i32 0
}