#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 */
typedef int /*<<< orphan*/ number;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int snprintf(char *, int, char *, int);
void printlevel(int level) {
  int len = 0;
  int targetlen = 4 + level;
  int shownlen = 0;
  char number[10];
  len = snprintf(number, sizeof(number), "<%d>", level);
  printf("%s", number);
  shownlen = len;
  while (shownlen < targetlen) {
    putchar(' ');
    ++shownlen;
  }
}


x86 assembly (clang, -O0):
<printlevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0xa,%esi
lea    0xe9b(%rip),%rdx
call   1050 <snprintf@plt>
mov    %eax,-0x8(%rbp)
lea    -0x1a(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a7 <printlevel+0x77>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1183 <printlevel+0x53>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printlevel>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0x4(%rbx),%r15d
lea    0xeb9(%rip),%rdx
lea    0xe(%rsp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
mov    %ebx,%ecx
call   1050 <snprintf@plt>
mov    %eax,%ebp
lea    0xea1(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
cmp    %r15d,%ebp
jge    118f <printlevel+0x5f>
sub    %ebp,%ebx
add    $0x4,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1180 <printlevel+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"<%d>\00"
@.str.1 = [3 x i8] c"%s\00"
define void @printlevel(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [10 x i8]
store i32 %0, i32* %2
store i32 0, i32* %3
%7 = load i32, i32* %2
%8 = add nsw i32 4, %7
store i32 %8, i32* %4
store i32 0, i32* %5
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%10 = load i32, i32* %2
%11 = call i32 @snprintf(i8* %9, i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 %11, i32* %3
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %3
store i32 %14, i32* %5
br label %15
15: ; preds = %19, %1
%16 = load i32, i32* %5
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = call i32 @putchar(i8 signext 32)
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %15
23: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"<%d>\00"
@.str.1 = [3 x i8] c"%s\00"
define void @printlevel(i32 %0) {
%2 = alloca [10 x i8]
%3 = add i32 %0, 4
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32 @snprintf(i8* %4, i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %0)
%6 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = icmp slt i32 %5, %3
br i1 %7, label %8, label %13
8: ; preds = %1, %8
%9 = phi i32 [ %11, %8 ], [ %5, %1 ]
%10 = call i32 @putchar(i8 signext 32)
%11 = add i32 %9, 1
%12 = icmp eq i32 %11, %3
br i1 %12, label %13, label %8
13: ; preds = %8, %1
ret void
}