#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 main() {
  int i;
  printf("# Push\n");
  for (i = 0x7F; i > 0; i--) {
    printf("MOV REGIST%02X REGIST%02X\n", i, i - 1);
  }
  printf("# Restore\n");
  for (i = 0; i < 0x7F; i++) {
    printf("MOV REGIST%02X REGIST%02X\n", i, i + 1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x7f,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1163 <main+0x53>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1134 <main+0x24>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7f,-0x8(%rbp)
jge    11a7 <main+0x97>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
add    $0x1,%edx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1178 <main+0x68>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x7f,%ebx
lea    0xec4(%rip),%r14
nopl   0x0(%rax)
lea    -0x1(%rbx),%ebp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
mov    %ebp,%ebx
ja     1140 <main+0x20>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe95(%rip),%rbx
xor    %esi,%esi
nopl   (%rax)
lea    0x1(%rsi),%ebp
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
cmp    $0x7f,%ebp
jne    1170 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"# Push\0A\00"
@.str.1 = [27 x i8] c"MOV REGIST%02X REGIST%02X\0A\00"
@.str.2 = [11 x i8] c"# Restore\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 127, i32* %2
br label %4
4: ; preds = %12, %0
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %10)
br label %12
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, -1
store i32 %14, i32* %2
br label %4
15: ; preds = %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %17
17: ; preds = %25, %15
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 127
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i32, i32* %2
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %23)
br label %25
25: ; preds = %20
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %17
28: ; preds = %17
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"MOV REGIST%02X REGIST%02X\0A\00"
@str = [7 x i8] c"# Push\00"
@str.3 = [10 x i8] c"# Restore\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 127, %0 ], [ %4, %2 ]
%4 = add nsw i32 %3, -1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %4)
%6 = icmp ugt i32 %3, 1
br i1 %6, label %2, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.3, i64 0, i64 0))
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ 0, %7 ], [ %11, %9 ]
%11 = add nuw nsw i32 %10, 1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %11)
%13 = icmp eq i32 %11, 127
br i1 %13, label %14, label %9
14: ; preds = %9
ret i32 0
}