#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*/ printf(char *, int, int, int, int);
int fun() {
  int x;
  int y;
  int z;
  int outer = 0;
  int inner = 0;
  for (x = 0; x < 2; x++) {
    for (y = 0; y < 2; y++) {
      for (z = 0; z < 2; z++) {
        ;
        outer++;
        printf("outer %d: x=%d y=%d z=%d\n", outer, x, y, z);
        {
          int x;
          int y;
          int z;
          for (x = 0; x < 2; x++) {
            for (y = 0; y < 2; y++) {
              for (z = 0; z < 2; z++) {
                ;
                inner++;
                printf("inner %d: x=%d y=%d z=%d\n", inner, x, y, z);
              }
            }
          }
        }
      }
    }
  }
  return inner + outer;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    123d <fun+0x12d>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    122a <fun+0x11a>
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    1217 <fun+0x107>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jge    1204 <fun+0xf4>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11f1 <fun+0xe1>
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jge    11de <fun+0xce>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a4 <fun+0x94>
jmp    11e3 <fun+0xd3>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1193 <fun+0x83>
jmp    11f6 <fun+0xe6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1182 <fun+0x72>
jmp    1209 <fun+0xf9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <fun+0x3f>
jmp    121c <fun+0x10c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113e <fun+0x2e>
jmp    122f <fun+0x11f>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112d <fun+0x1d>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x1,%al
xor    %ebx,%ebx
lea    0xef1(%rip),%r15
xor    %r12d,%r12d
xor    %ecx,%ecx
xchg   %ax,%ax
mov    %ecx,0xc(%rsp)
mov    %eax,0x8(%rsp)
mov    %ebx,%r14d
xor    %ebx,%ebx
mov    %r12d,%edx
mov    $0x1,%al
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,0x10(%rsp)
mov    %edx,0x14(%rsp)
lea    0x1(%r12),%esi
lea    0xe9c(%rip),%rdi
mov    0xc(%rsp),%r13d
mov    %r13d,%edx
mov    %ebp,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x1,%esi
mov    %r15,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x2,%esi
mov    %r15,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x3,%esi
mov    %r15,%rdi
xor    %edx,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x4,%esi
mov    %r15,%rdi
xor    %edx,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x5,%esi
mov    %r15,%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x6,%esi
mov    %r15,%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x7,%esi
mov    %r15,%rdi
mov    $0x1,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x8,%esi
mov    %r15,%rdi
mov    $0x1,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
add    $0x2,%r12d
lea    0xdab(%rip),%rdi
mov    %r12d,%esi
mov    %r13d,%edx
mov    %ebp,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x9,%esi
mov    %r15,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0xa,%esi
mov    %r15,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0xb,%esi
mov    %r15,%rdi
xor    %edx,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0xc,%esi
mov    %r15,%rdi
xor    %edx,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0xd,%esi
mov    %r15,%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0xe,%esi
mov    %r15,%rdi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0xf,%esi
mov    %r15,%rdi
mov    $0x1,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%esi
add    $0x10,%esi
mov    %r15,%rdi
mov    $0x1,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   1030 <printf@plt>
mov    0x14(%rsp),%edx
add    $0x12,%edx
add    $0x10,%ebx
mov    $0x1,%ebp
testb  $0x1,0x10(%rsp)
mov    $0x0,%eax
jne    1150 <fun+0x40>
add    %r14d,%ebx
mov    $0x1,%ecx
testb  $0x1,0x8(%rsp)
mov    $0x0,%eax
jne    1130 <fun+0x20>
add    %edx,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"outer %d: x=%d y=%d z=%d\0A\00"
@.str.1 = [26 x i8] c"inner %d: x=%d y=%d z=%d\0A\00"
define i32 @fun() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %1
br label %9
9: ; preds = %67, %0
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %70
12: ; preds = %9
store i32 0, i32* %2
br label %13
13: ; preds = %63, %12
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %66
16: ; preds = %13
store i32 0, i32* %3
br label %17
17: ; preds = %59, %16
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %62
20: ; preds = %17
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24, i32 %25, i32 %26)
store i32 0, i32* %6
br label %28
28: ; preds = %55, %20
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 2
br i1 %30, label %31, label %58
31: ; preds = %28
store i32 0, i32* %7
br label %32
32: ; preds = %51, %31
%33 = load i32, i32* %7
%34 = icmp slt i32 %33, 2
br i1 %34, label %35, label %54
35: ; preds = %32
store i32 0, i32* %8
br label %36
36: ; preds = %47, %35
%37 = load i32, i32* %8
%38 = icmp slt i32 %37, 2
br i1 %38, label %39, label %50
39: ; preds = %36
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = load i32, i32* %8
%46 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 %43, i32 %44, i32 %45)
br label %47
47: ; preds = %39
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %36
50: ; preds = %36
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %32
54: ; preds = %32
br label %55
55: ; preds = %54
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %28
58: ; preds = %28
br label %59
59: ; preds = %58
%60 = load i32, i32* %3
%61 = add nsw i32 %60, 1
store i32 %61, i32* %3
br label %17
62: ; preds = %17
br label %63
63: ; preds = %62
%64 = load i32, i32* %2
%65 = add nsw i32 %64, 1
store i32 %65, i32* %2
br label %13
66: ; preds = %13
br label %67
67: ; preds = %66
%68 = load i32, i32* %1
%69 = add nsw i32 %68, 1
store i32 %69, i32* %1
br label %9
70: ; preds = %9
%71 = load i32, i32* %5
%72 = load i32, i32* %4
%73 = add nsw i32 %71, %72
ret i32 %73
}

LLVM IR (-O2):
@.str = [26 x i8] c"outer %d: x=%d y=%d z=%d\0A\00"
@.str.1 = [26 x i8] c"inner %d: x=%d y=%d z=%d\0A\00"
define i32 @fun() {
br label %1
1: ; preds = %0, %47
%2 = phi i32 [ 0, %0 ], [ %45, %47 ]
%3 = phi i32 [ 0, %0 ], [ %29, %47 ]
%4 = phi i1 [ true, %0 ], [ false, %47 ]
%5 = phi i32 [ 0, %0 ], [ 1, %47 ]
br label %6
6: ; preds = %1, %6
%7 = phi i32 [ %2, %1 ], [ %45, %6 ]
%8 = phi i32 [ %3, %1 ], [ %29, %6 ]
%9 = phi i1 [ true, %1 ], [ false, %6 ]
%10 = phi i32 [ 0, %1 ], [ 1, %6 ]
%11 = add nsw i32 %8, 1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %5, i32 %10, i32 0)
%13 = add nsw i32 %7, 1
%14 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 0, i32 0, i32 0)
%15 = add nsw i32 %7, 2
%16 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 0, i32 0, i32 1)
%17 = add nsw i32 %7, 3
%18 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 0, i32 1, i32 0)
%19 = add nsw i32 %7, 4
%20 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 0, i32 1, i32 1)
%21 = add nsw i32 %7, 5
%22 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 1, i32 0, i32 0)
%23 = add nsw i32 %7, 6
%24 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 1, i32 0, i32 1)
%25 = add nsw i32 %7, 7
%26 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 1, i32 1, i32 0)
%27 = add nsw i32 %7, 8
%28 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 1, i32 1, i32 1)
%29 = add nsw i32 %8, 2
%30 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %5, i32 %10, i32 1)
%31 = add nsw i32 %7, 9
%32 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 0, i32 0, i32 0)
%33 = add nsw i32 %7, 10
%34 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 0, i32 0, i32 1)
%35 = add nsw i32 %7, 11
%36 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 0, i32 1, i32 0)
%37 = add nsw i32 %7, 12
%38 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 0, i32 1, i32 1)
%39 = add nsw i32 %7, 13
%40 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 1, i32 0, i32 0)
%41 = add nsw i32 %7, 14
%42 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 1, i32 0, i32 1)
%43 = add nsw i32 %7, 15
%44 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 1, i32 1, i32 0)
%45 = add nsw i32 %7, 16
%46 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %45, i32 1, i32 1, i32 1)
br i1 %9, label %6, label %47
47: ; preds = %6
br i1 %4, label %1, label %48
48: ; preds = %47
%49 = add nsw i32 %45, %29
ret i32 %49
}