#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 */
char *ho_trim(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char buf[128];
  strcpy(buf, "    1234    ");
  printf("$%s:\n", ho_trim(buf));
  strcpy(buf, "1234    ");
  printf("$%s:\n", ho_trim(buf));
  strcpy(buf, "    1234");
  printf("$%s:\n", ho_trim(buf));
  strcpy(buf, "    1234  abcd   ");
  printf("$%s:\n", ho_trim(buf));
  strcpy(buf, "    ");
  printf("$%s:\n", ho_trim(buf));
  strcpy(buf, " ");
  printf("$%s:\n", ho_trim(buf));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x90(%rbp),%rdi
call   1030 <ho_trim@plt>
mov    %rax,%rsi
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x90(%rbp),%rdi
call   1030 <ho_trim@plt>
mov    %rax,%rsi
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x90(%rbp),%rdi
call   1030 <ho_trim@plt>
mov    %rax,%rsi
lea    0xe46(%rip),%rdi
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x90(%rbp),%rdi
call   1030 <ho_trim@plt>
mov    %rax,%rsi
lea    0xe18(%rip),%rdi
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x90(%rbp),%rdi
call   1030 <ho_trim@plt>
mov    %rax,%rsi
lea    0xdea(%rip),%rdi
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xdd5(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x90(%rbp),%rdi
call   1030 <ho_trim@plt>
mov    %rax,%rsi
lea    0xdbc(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xebf(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <ho_trim@plt>
lea    0xeb2(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <ho_trim@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <ho_trim@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <ho_trim@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <ho_trim@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe16(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <ho_trim@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c" 1234 \00"
@.str.1 = [6 x i8] c"$%s:\0A\00"
@.str.2 = [9 x i8] c"1234 \00"
@.str.3 = [9 x i8] c" 1234\00"
@.str.4 = [18 x i8] c" 1234 abcd \00"
@.str.5 = [5 x i8] c" \00"
@.str.6 = [2 x i8] c" \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = call i8* @ho_trim(i8* %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%11 = call i8* @ho_trim(i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%16 = call i8* @ho_trim(i8* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%21 = call i8* @ho_trim(i8* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%26 = call i8* @ho_trim(i8* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%31 = call i8* @ho_trim(i8* %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c" 1234 \00"
@.str.1 = [6 x i8] c"$%s:\0A\00"
@.str.2 = [9 x i8] c"1234 \00"
@.str.3 = [9 x i8] c" 1234\00"
@.str.4 = [18 x i8] c" 1234 abcd \00"
@.str.5 = [5 x i8] c" \00"
@.str.6 = [2 x i8] c" \00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i8* @ho_trim(i8* %2)
%5 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%7 = call i8* @ho_trim(i8* %2)
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%10 = call i8* @ho_trim(i8* %2)
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%13 = call i8* @ho_trim(i8* %2)
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%16 = call i8* @ho_trim(i8* %2)
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%19 = call i8* @ho_trim(i8* %2)
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %19)
ret i32 0
}