#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*/ detab(char *, int);
int /*<<< orphan*/ entab(char *, int);
int getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printline(char *);
int strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  char line[1024];
  char before[1024];
  int len;
  printf("testing for detab and entab, first detab, then entab\n"
         "input a line with tabs:\n");
  len = getline(line, 1024);
  printf("the string you input just now is:\n'%s'\n", line);
  printline(line);
  strcpy(before, line);
  detab(line, len);
  printf("after detabing is:\n'%s'\n", line);
  printline(line);
  entab(line, len);
  printf("after converting, the string is:\n'%s'\n", line);
  printline(line);
  printf("testing result is: %d\n", strcmp(before, line));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   1080 <getline@plt>
mov    %eax,-0x814(%rbp)
lea    -0x410(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
call   1070 <printline@plt>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
mov    -0x814(%rbp),%esi
call   1040 <detab@plt>
lea    -0x410(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
call   1070 <printline@plt>
lea    -0x410(%rbp),%rdi
mov    -0x814(%rbp),%esi
call   1090 <entab@plt>
lea    -0x410(%rbp),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
call   1070 <printline@plt>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x800,%rsp
lea    0xeed(%rip),%rdi
call   1040 <puts@plt>
lea    0x400(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1090 <getline@plt>
mov    %eax,%ebp
lea    0xe4b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1080 <printline@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <detab@plt>
lea    0xe42(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1080 <printline@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10a0 <entab@plt>
lea    0xe38(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1080 <printline@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
lea    0xe3b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [78 x i8] c"testing for detab and entab, first detab, then entab\0Ainput a line with tabs:\0A\00"
@.str.1 = [40 x i8] c"the string you input just now is:\0A'%s'\0A\00"
@.str.2 = [25 x i8] c"after detabing is:\0A'%s'\0A\00"
@.str.3 = [39 x i8] c"after converting, the string is:\0A'%s'\0A\00"
@.str.4 = [23 x i8] c"testing result is: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = call i32 @getline(i8* %10, i32 1024)
store i32 %11, i32* %8
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = call i32 @printline(i8* %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%20 = load i32, i32* %8
%21 = call i32 @detab(i8* %19, i32 %20)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%25 = call i32 @printline(i8* %24)
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%27 = load i32, i32* %8
%28 = call i32 @entab(i8* %26, i32 %27)
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%32 = call i32 @printline(i8* %31)
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%35 = call i32 @strcmp(i8* %33, i8* %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [40 x i8] c"the string you input just now is:\0A'%s'\0A\00"
@.str.2 = [25 x i8] c"after detabing is:\0A'%s'\0A\00"
@.str.3 = [39 x i8] c"after converting, the string is:\0A'%s'\0A\00"
@.str.4 = [23 x i8] c"testing result is: %d\0A\00"
@str = [77 x i8] c"testing for detab and entab, first detab, then entab\0Ainput a line with tabs:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str, i64 0, i64 0))
%8 = call i32 @getline(i8* %5, i32 1024)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%10 = call i32 @printline(i8* %5)
%11 = call i32 @strcpy(i8* %6, i8* %5)
%12 = call i32 @detab(i8* %5, i32 %8)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%14 = call i32 @printline(i8* %5)
%15 = call i32 @entab(i8* %5, i32 %8)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%17 = call i32 @printline(i8* %5)
%18 = call i32 @strcmp(i8* %6, i8* %5)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %18)
ret i32 0
}