#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 getbits(unsigned int, int, int);
int /*<<< orphan*/ printbits(int, int);
int /*<<< orphan*/ printf(char *, ...);
main() {
  unsigned t = 15;
  int i, j;
  for (t = 0; t < 16; t++) {
    for (i = 0; i < 4; i++)
      for (j = 1; j <= 4; j++) {
        printf("%d, %d, %06.x, %06.x  ", i, j, t, getbits(t, i, j));
        printbits(getbits(t, i, j), 8);
        printf("\n");
      }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf,-0x8(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x10,-0x8(%rbp)
jae    120f <main+0xdf>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11fc <main+0xcc>
movl   $0x1,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jg     11e9 <main+0xb9>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <getbits@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    %eax,%r8d
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <getbits@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1040 <printbits@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <main+0x3f>
jmp    11ee <main+0xbe>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115e <main+0x2e>
jmp    1201 <main+0xd1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xeb5(%rip),%r14
xor    %ebp,%ebp
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
call   1060 <getbits@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
call   1060 <getbits@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1050 <printbits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x2,%edx
call   1060 <getbits@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x2,%edx
call   1060 <getbits@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1050 <printbits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x3,%edx
call   1060 <getbits@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x3,%edx
call   1060 <getbits@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1050 <printbits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x4,%edx
call   1060 <getbits@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x4,%edx
call   1060 <getbits@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1050 <printbits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    $0x4,%ebx
jne    1160 <main+0x20>
add    $0x1,%ebp
cmp    $0x10,%ebp
jne    1150 <main+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"%d, %d, %06.x, %06.x \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 15, i32* %2
store i32 0, i32* %2
br label %5
5: ; preds = %39, %0
%6 = load i32, i32* %2
%7 = icmp ult i32 %6, 16
br i1 %7, label %8, label %42
8: ; preds = %5
store i32 0, i32* %3
br label %9
9: ; preds = %35, %8
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %38
12: ; preds = %9
store i32 1, i32* %4
br label %13
13: ; preds = %31, %12
%14 = load i32, i32* %4
%15 = icmp sle i32 %14, 4
br i1 %15, label %16, label %34
16: ; preds = %13
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @getbits(i32 %20, i32 %21, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18, i32 %19, i32 %23)
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = call i32 @getbits(i32 %25, i32 %26, i32 %27)
%29 = call i32 @printbits(i32 %28, i32 8)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %16
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %13
34: ; preds = %13
br label %35
35: ; preds = %34
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %9
38: ; preds = %9
br label %39
39: ; preds = %38
%40 = load i32, i32* %2
%41 = add i32 %40, 1
store i32 %41, i32* %2
br label %5
42: ; preds = %5
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [23 x i8] c"%d, %d, %06.x, %06.x \00"
define i32 @main() {
br label %1
1: ; preds = %0, %27
%2 = phi i32 [ 0, %0 ], [ %28, %27 ]
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 0, %1 ], [ %25, %3 ]
%5 = tail call i32 @getbits(i32 %2, i32 %4, i32 1)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4, i32 1, i32 %2, i32 %5)
%7 = tail call i32 @getbits(i32 %2, i32 %4, i32 1)
%8 = tail call i32 @printbits(i32 %7, i32 8)
%9 = tail call i32 @putchar(i32 10)
%10 = tail call i32 @getbits(i32 %2, i32 %4, i32 2)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4, i32 2, i32 %2, i32 %10)
%12 = tail call i32 @getbits(i32 %2, i32 %4, i32 2)
%13 = tail call i32 @printbits(i32 %12, i32 8)
%14 = tail call i32 @putchar(i32 10)
%15 = tail call i32 @getbits(i32 %2, i32 %4, i32 3)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4, i32 3, i32 %2, i32 %15)
%17 = tail call i32 @getbits(i32 %2, i32 %4, i32 3)
%18 = tail call i32 @printbits(i32 %17, i32 8)
%19 = tail call i32 @putchar(i32 10)
%20 = tail call i32 @getbits(i32 %2, i32 %4, i32 4)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4, i32 4, i32 %2, i32 %20)
%22 = tail call i32 @getbits(i32 %2, i32 %4, i32 4)
%23 = tail call i32 @printbits(i32 %22, i32 8)
%24 = tail call i32 @putchar(i32 10)
%25 = add nuw nsw i32 %4, 1
%26 = icmp eq i32 %25, 4
br i1 %26, label %27, label %3
27: ; preds = %3
%28 = add nuw nsw i32 %2, 1
%29 = icmp eq i32 %28, 16
br i1 %29, label %30, label %1
30: ; preds = %27
ret i32 0
}