#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*/ ask_newline();
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void print_n_times_x(long n, int x) {
  long i;
  if (n < 0)
    for (i = -n; i > 0; i--) {
      fputc(x - 1, stdout);
      ask_newline();
    }
  if (n > 0)
    for (i = n; i > 0; i--) {
      fputc(x + 1, stdout);
      ask_newline();
    }
}


x86 assembly (clang, -O0):
<print_n_times_x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    1180 <print_n_times_x+0x60>
xor    %eax,%eax
sub    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    117b <print_n_times_x+0x5b>
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
call   1030 <fputc@plt>
mov    $0x0,%al
call   1040 <ask_newline@plt>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1144 <print_n_times_x+0x24>
jmp    1180 <print_n_times_x+0x60>
cmpq   $0x0,-0x8(%rbp)
jle    11cf <print_n_times_x+0xaf>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    11ca <print_n_times_x+0xaa>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
call   1030 <fputc@plt>
mov    $0x0,%al
call   1040 <ask_newline@plt>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1193 <print_n_times_x+0x73>
jmp    11cf <print_n_times_x+0xaf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_n_times_x>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
test   %rdi,%rdi
jns    116d <print_n_times_x+0x4d>
lea    -0x1(%r14),%r15d
mov    $0x1,%ebp
sub    %rbx,%rbp
mov    0x2e9a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    (%r12),%esi
mov    %r15d,%edi
call   1030 <fputc@plt>
xor    %eax,%eax
call   1040 <ask_newline@plt>
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
ja     1150 <print_n_times_x+0x30>
test   %rbx,%rbx
jle    11ac <print_n_times_x+0x8c>
add    $0x1,%r14d
add    $0x1,%rbx
mov    0x2e5f(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%esi
mov    %r14d,%edi
call   1030 <fputc@plt>
xor    %eax,%eax
call   1040 <ask_newline@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1190 <print_n_times_x+0x70>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
define void @print_n_times_x(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i64
store i64 %0, i64* %3
store i32 %1, i32* %4
%6 = load i64, i64* %3
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %2
%9 = load i64, i64* %3
%10 = sub nsw i64 0, %9
store i64 %10, i64* %5
br label %11
11: ; preds = %20, %8
%12 = load i64, i64* %5
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 1
%17 = load i32, i32* @stdout
%18 = call i32 @fputc(i32 %16, i32 %17)
%19 = call i32 (...) @ask_newline()
br label %20
20: ; preds = %14
%21 = load i64, i64* %5
%22 = add nsw i64 %21, -1
store i64 %22, i64* %5
br label %11
23: ; preds = %11
br label %24
24: ; preds = %23, %2
%25 = load i64, i64* %3
%26 = icmp sgt i64 %25, 0
br i1 %26, label %27, label %42
27: ; preds = %24
%28 = load i64, i64* %3
store i64 %28, i64* %5
br label %29
29: ; preds = %38, %27
%30 = load i64, i64* %5
%31 = icmp sgt i64 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
%35 = load i32, i32* @stdout
%36 = call i32 @fputc(i32 %34, i32 %35)
%37 = call i32 (...) @ask_newline()
br label %38
38: ; preds = %32
%39 = load i64, i64* %5
%40 = add nsw i64 %39, -1
store i64 %40, i64* %5
br label %29
41: ; preds = %29
br label %42
42: ; preds = %41, %24
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @print_n_times_x(i64 %0, i32 %1) {
%3 = icmp slt i64 %0, 0
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = sub nsw i64 0, %0
%6 = add nsw i32 %1, -1
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ %5, %4 ], [ %12, %7 ]
%9 = load i32, i32* @stdout
%10 = tail call i32 @fputc(i32 %6, i32 %9)
%11 = tail call i32 (...) @ask_newline()
%12 = add nsw i64 %8, -1
%13 = icmp ugt i64 %8, 1
br i1 %13, label %7, label %14
14: ; preds = %7, %2
%15 = icmp sgt i64 %0, 0
br i1 %15, label %16, label %25
16: ; preds = %14
%17 = add nsw i32 %1, 1
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ %0, %16 ], [ %23, %18 ]
%20 = load i32, i32* @stdout
%21 = tail call i32 @fputc(i32 %17, i32 %20)
%22 = tail call i32 (...) @ask_newline()
%23 = add nsw i64 %19, -1
%24 = icmp ugt i64 %19, 1
br i1 %24, label %18, label %25
25: ; preds = %18, %14
ret void
}