#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 */
struct buf_output {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ __log_buf(struct buf_output *, char *);
int /*<<< orphan*/ log_info(char *);
void json_print_level(int level, struct buf_output *out) {
  while (level-- > 0)
    do {
      if ((out) != NULL)
        __log_buf(out, "  ");
      else
        log_info("  ");
    } while (0);
}


x86 assembly (clang, -O0):
<json_print_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
jle    117e <json_print_level+0x5e>
jmp    1148 <json_print_level+0x28>
cmpq   $0x0,-0x10(%rbp)
je     1168 <json_print_level+0x48>
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1040 <__log_buf@plt>
jmp    1174 <json_print_level+0x54>
lea    0xe91(%rip),%rdi
call   1030 <log_info@plt>
jmp    1179 <json_print_level+0x59>
jmp    112f <json_print_level+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<json_print_level>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
jle    1162 <json_print_level+0x42>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x1,%ebp
lea    0xec9(%rip),%r14
jmp    1150 <json_print_level+0x30>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <log_info@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jbe    1162 <json_print_level+0x42>
test   %rbx,%rbx
je     1140 <json_print_level+0x20>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <__log_buf@plt>
jmp    1148 <json_print_level+0x28>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.buf_output = type { i32 }
@.str = [3 x i8] c" \00"
define void @json_print_level(i32 %0, %struct.buf_output* %1) {
%3 = alloca i32
%4 = alloca %struct.buf_output*
store i32 %0, i32* %3
store %struct.buf_output* %1, %struct.buf_output** %4
br label %5
5: ; preds = %19, %2
%6 = load i32, i32* %3
%7 = add nsw i32 %6, -1
store i32 %7, i32* %3
%8 = icmp sgt i32 %6, 0
br i1 %8, label %9, label %20
9: ; preds = %5
br label %10
10: ; preds = %9
%11 = load %struct.buf_output*, %struct.buf_output** %4
%12 = icmp ne %struct.buf_output* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load %struct.buf_output*, %struct.buf_output** %4
%15 = call i32 @__log_buf(%struct.buf_output* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %18
16: ; preds = %10
%17 = call i32 @log_info(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
br label %19
19: ; preds = %18
br label %5
20: ; preds = %5
ret void
}

LLVM IR (-O2):
%struct.buf_output = type { i32 }
@.str = [3 x i8] c" \00"
define void @json_print_level(i32 %0, %struct.buf_output* %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = icmp eq %struct.buf_output* %1, null
br label %6
6: ; preds = %4, %13
%7 = phi i32 [ %0, %4 ], [ %8, %13 ]
%8 = add nsw i32 %7, -1
br i1 %5, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @__log_buf(%struct.buf_output* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %6
%12 = tail call i32 @log_info(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %9, %11
%14 = icmp ugt i32 %7, 1
br i1 %14, label %6, label %15
15: ; preds = %13, %2
ret void
}