#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 invert(int, int, int);
int /*<<< orphan*/ printbits(int, int);
int /*<<< orphan*/ printf(char *, ...);
main() {
  int x, i, j;
  x = 123;
  for (i = 1; i < 8; i++) {
    for (j = 1; j <= i; j++) {
      printf("x   ");
      printbits(x, 8);
      printf("\n");
      printf("%d %d ", i, j);
      printbits(invert(x, i, j), 8);
      printf("\n");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x7b,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11f9 <main+0xc9>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11dd <main+0xad>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1050 <printbits@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <invert@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1050 <printbits@plt>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115e <main+0x2e>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebp
mov    $0x2,%r12d
lea    0xea3(%rip),%r14
lea    0xea1(%rip),%r15
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7b,%edi
mov    $0x8,%esi
call   1060 <printbits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7b,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <invert@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1060 <printbits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x2,%eax
jne    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
add    $0x1,%r12d
add    $0xffffffff,%r13d
cmp    $0x9,%r12d
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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