#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*/ putd(int);
int /*<<< orphan*/ puts(char *);
void emitlocal(char reg[], int offset) {
  puts("\tlea ");
  puts(reg);
  puts(", [ebp");
  offset *= 4;
  if (offset < 0) {
    puts(" - ");
    putd(-offset);
  } else if (offset) {
    puts(" + ");
    putd(offset);
  }
  puts("]\n");
}


x86 assembly (clang, -O0):
<emitlocal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
mov    -0xc(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    117e <emitlocal+0x5e>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
sub    -0xc(%rbp),%edi
call   1040 <putd@plt>
jmp    11a1 <emitlocal+0x81>
cmpl   $0x0,-0xc(%rbp)
je     119c <emitlocal+0x7c>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
mov    -0xc(%rbp),%edi
call   1040 <putd@plt>
jmp    11a1 <emitlocal+0x81>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emitlocal>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rbp
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0x0(,%rbx,4),%ebp
test   %ebx,%ebx
js     1163 <emitlocal+0x43>
je     1178 <emitlocal+0x58>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
jmp    1171 <emitlocal+0x51>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
neg    %ebp
mov    %ebp,%edi
call   1040 <putd@plt>
lea    0xe96(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\09lea \00"
@.str.1 = [7 x i8] c", [ebp\00"
@.str.2 = [4 x i8] c" - \00"
@.str.3 = [4 x i8] c" + \00"
@.str.4 = [3 x i8] c"]\0A\00"
define void @emitlocal(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %3
%7 = call i32 @puts(i8* %6)
%8 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* %4
%10 = mul nsw i32 %9, 4
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* %4
%16 = sub nsw i32 0, %15
%17 = call i32 @putd(i32 %16)
br label %26
18: ; preds = %2
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* %4
%24 = call i32 @putd(i32 %23)
br label %25
25: ; preds = %21, %18
br label %26
26: ; preds = %25, %13
%27 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\09lea \00"
@.str.1 = [7 x i8] c", [ebp\00"
@.str.2 = [4 x i8] c" - \00"
@.str.3 = [4 x i8] c" + \00"
@.str.4 = [3 x i8] c"]\0A\00"
define void @emitlocal(i8* nocapture %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) %0)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%6 = shl nsw i32 %1, 2
%7 = icmp slt i32 %1, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = sub nsw i32 0, %6
br label %15
11: ; preds = %2
%12 = icmp eq i32 %1, 0
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %8, %13
%16 = phi i32 [ %6, %13 ], [ %10, %8 ]
%17 = tail call i32 @putd(i32 %16)
br label %18
18: ; preds = %15, %11
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
ret void
}