#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*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void Add_Tick(char *line, int count, int length) {
  int space;
  char tick[20];
  sprintf(tick, "%d", count);
  space = length + 9 - strlen(line) - strlen(tick);
  if (space > 0) {
    while (space > 0) {
      strcat(line, " ");
      --space;
    }
    strcat(line, tick);
  }
}


x86 assembly (clang, -O0):
<Add_Tick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xeb0(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x9,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11c8 <Add_Tick+0x98>
jmp    1193 <Add_Tick+0x63>
cmpl   $0x0,-0x14(%rbp)
jle    11bb <Add_Tick+0x8b>
mov    -0x8(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <Add_Tick+0x63>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <strcat@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Add_Tick>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %esi,%edx
mov    %rdi,%r14
lea    0xeb8(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1050 <sprintf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
sub    %eax,%ebx
lea    0x9(%rbx),%eax
test   %eax,%eax
jle    119e <Add_Tick+0x6e>
add    $0xa,%ebx
lea    0xe89(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1180 <Add_Tick+0x50>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c" \00"
define void @Add_Tick(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [20 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%10 = load i32, i32* %5
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 9
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %13, %15
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = sub nsw i32 %16, %18
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %3
br label %23
23: ; preds = %26, %22
%24 = load i32, i32* %7
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8*, i8** %4
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* %7
%30 = add nsw i32 %29, -1
store i32 %30, i32* %7
br label %23
31: ; preds = %23
%32 = load i8*, i8** %4
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%34 = call i32 @strcat(i8* %32, i8* %33)
br label %35
35: ; preds = %31, %3
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c" \00"
define void @Add_Tick(i8* %0, i32 %1, i32 %2) {
%4 = alloca [20 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%7 = tail call i32 @strlen(i8* %0)
%8 = call i32 @strlen(i8* %5)
%9 = add i32 %2, 9
%10 = add i32 %7, %8
%11 = sub i32 %9, %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %3, %13
%14 = phi i32 [ %16, %13 ], [ %11, %3 ]
%15 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = add nsw i32 %14, -1
%17 = icmp ugt i32 %14, 1
br i1 %17, label %13, label %18
18: ; preds = %13
%19 = call i32 @strcat(i8* %0, i8* %5)
br label %20
20: ; preds = %18, %3
ret void
}