#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 compact1(char *);
int compact2(char *);
int getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  char buffer1[128];
  char buffer2[128];
  int len;
  len = getline(buffer1, 128);
  printf("You entered : %s\n", buffer1);
  strcpy(buffer2, buffer1);
  printf("Which is : %s\n", buffer2);
  len = compact1(buffer1);
  printf("compact1: len=%d,  %s\n", len, buffer1);
  len = compact2(buffer2);
  printf("compact2: len=%d,  %s\n", len, buffer2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    -0x80(%rbp),%rdi
mov    $0x80,%esi
call   1070 <getline@plt>
mov    %eax,-0x104(%rbp)
lea    -0x80(%rbp),%rsi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x100(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1040 <compact1@plt>
mov    %eax,-0x104(%rbp)
mov    -0x104(%rbp),%esi
lea    -0x80(%rbp),%rdx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x100(%rbp),%rdi
call   1060 <compact2@plt>
mov    %eax,-0x104(%rbp)
mov    -0x104(%rbp),%esi
lea    -0x100(%rbp),%rdx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1070 <getline@plt>
lea    0xe8a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe7d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <compact1@plt>
lea    0xe73(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1060 <compact2@plt>
lea    0xe6f(%rip),%rdi
mov    %eax,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"You entered : %s\0A\00"
@.str.1 = [15 x i8] c"Which is : %s\0A\00"
@.str.2 = [23 x i8] c"compact1: len=%d, %s\0A\00"
@.str.3 = [23 x i8] c"compact2: len=%d, %s\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%5 = call i32 @getline(i8* %4, i32 128)
store i32 %5, i32* %3
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%10 = call i32 @strcpy(i8* %8, i8* %9)
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%14 = call i32 @compact1(i8* %13)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %15, i8* %16)
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%19 = call i32 @compact2(i8* %18)
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %20, i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"You entered : %s\0A\00"
@.str.1 = [15 x i8] c"Which is : %s\0A\00"
@.str.2 = [23 x i8] c"compact1: len=%d, %s\0A\00"
@.str.3 = [23 x i8] c"compact2: len=%d, %s\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = call i32 @getline(i8* %3, i32 128)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = call i32 @strcpy(i8* %4, i8* %3)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 @compact1(i8* %3)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %9, i8* %3)
%11 = call i32 @compact2(i8* %4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %11, i8* %4)
ret i32 0
}