#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 EXIT_SUCCESS;
int mygetchar();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  char cadena[200];
  int i = 0, car;
  printf("\nIntroduix el text acabat en INTRO:\n");
  while (i < 200 - 1 && (car = mygetchar()) != '\n') {
    cadena[i] = car;
    i++;
  }
  cadena[i] = 0;
  printf("\n\nEl text %s al reves és\n", cadena);
  i--;
  while (i >= 0)
    printf("%c", cadena[i--]);
  printf("\n\n");
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xe4(%rbp)
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
cmpl   $0xc7,-0xe4(%rbp)
mov    %al,-0xe9(%rbp)
jge    1182 <main+0x62>
mov    $0x0,%al
call   1030 <mygetchar@plt>
mov    %eax,-0xe8(%rbp)
cmp    $0xa,%eax
setne  %al
mov    %al,-0xe9(%rbp)
mov    -0xe9(%rbp),%al
test   $0x1,%al
jne    1195 <main+0x75>
jmp    11bf <main+0x9f>
mov    -0xe8(%rbp),%eax
mov    %al,%cl
movslq -0xe4(%rbp),%rax
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1151 <main+0x31>
movslq -0xe4(%rbp),%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    -0xe0(%rbp),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xe4(%rbp)
cmpl   $0x0,-0xe4(%rbp)
jl     122d <main+0x10d>
mov    -0xe4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xe4(%rbp)
cltq
movsbl -0xe0(%rbp,%rax,1),%esi
ff
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f2 <main+0xd2>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xd0,%rsp
lea    0xecc(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <mygetchar@plt>
cmp    $0xa,%eax
je     119c <main+0x5c>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0xc7,%rbx
jne    1160 <main+0x20>
movb   $0x0,0xc7(%rsp)
lea    0xe75(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xc7,%ebx
jmp    11b5 <main+0x75>
movb   $0x0,(%rsp,%rbx,1)
lea    0xe59(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebx,%ebx
jle    11d4 <main+0x94>
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl -0x2(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11c0 <main+0x80>
lea    0xe3e(%rip),%rdi
call   1040 <puts@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
add    $0xd0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"\0AIntroduix el text acabat en INTRO:\0A\00"
@.str.1 = [27 x i8] c"\0A\0AEl text %s al reves \C3\A9s\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [200 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %18, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 199
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 (...) @mygetchar()
store i32 %14, i32* %8
%15 = icmp ne i32 %14, 10
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ false, %10 ], [ %15, %13 ]
br i1 %17, label %18, label %26
18: ; preds = %16
%19 = load i32, i32* %8
%20 = trunc i32 %19 to i8
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 %22
store i8 %20, i8* %23
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %10
26: ; preds = %16
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 %28
store i8 0, i8* %29
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* %7
%33 = add nsw i32 %32, -1
store i32 %33, i32* %7
br label %34
34: ; preds = %37, %26
%35 = load i32, i32* %7
%36 = icmp sge i32 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %34
%38 = load i32, i32* %7
%39 = add nsw i32 %38, -1
store i32 %39, i32* %7
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %34
45: ; preds = %34
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"\0A\0AEl text %s al reves \C3\A9s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [36 x i8] c"\0AIntroduix el text acabat en INTRO:\00"
@str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %6
6: ; preds = %2, %10
%7 = phi i64 [ 0, %2 ], [ %13, %10 ]
%8 = tail call i32 (...) @mygetchar()
%9 = icmp eq i32 %8, 10
br i1 %9, label %18, label %10
10: ; preds = %6
%11 = trunc i32 %8 to i8
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %7
store i8 %11, i8* %12
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, 199
br i1 %14, label %15, label %6
15: ; preds = %10
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 199
store i8 0, i8* %16
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %24
18: ; preds = %6
%19 = trunc i64 %7 to i32
%20 = and i64 %7, 4294967295
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %20
store i8 0, i8* %21
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%23 = icmp sgt i32 %19, 0
br i1 %23, label %24, label %34
24: ; preds = %15, %18
%25 = phi i64 [ %20, %18 ], [ 199, %15 ]
br label %26
26: ; preds = %24, %26
%27 = phi i64 [ %28, %26 ], [ %25, %24 ]
%28 = add nsw i64 %27, -1
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i32 @putchar(i32 %31)
%33 = icmp ugt i64 %27, 1
br i1 %33, label %26, label %34
34: ; preds = %26, %18
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0))
%36 = load i32, i32* @EXIT_SUCCESS
ret i32 %36
}