#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[45];
  int i = 0, car;
  printf("Introdueix el nom de l'usuari\n");
  while (i < 45 - 1 && (car = mygetchar()) != '\n') {
    cadena[i] = car;
    i++;
  }
  cadena[i] = 0;
  printf("El nom de l'usuari introduix es %s\n", cadena);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
cmpl   $0x2c,-0x44(%rbp)
mov    %al,-0x49(%rbp)
jge    116d <main+0x4d>
mov    $0x0,%al
call   1030 <mygetchar@plt>
mov    %eax,-0x48(%rbp)
cmp    $0xa,%eax
setne  %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    117d <main+0x5d>
jmp    1198 <main+0x78>
mov    -0x48(%rbp),%eax
mov    %al,%cl
movslq -0x44(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    114b <main+0x2b>
movslq -0x44(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <mygetchar@plt>
cmp    $0xa,%eax
je     116e <main+0x3e>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x2c,%rbx
jne    1150 <main+0x20>
mov    $0x2c,%ebx
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe85(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Introdueix el nom de l'usuari\0A\00"
@.str.1 = [36 x i8] c"El nom de l'usuari introduix es %s\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 [45 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 ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %18, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 44
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 [45 x i8], [45 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 [45 x i8], [45 x i8]* %6, i64 0, i64 %28
store i8 0, i8* %29
%30 = getelementptr inbounds [45 x i8], [45 x i8]* %6, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @EXIT_SUCCESS
ret i32 %32
}

LLVM IR (-O2):
@.str.1 = [36 x i8] c"El nom de l'usuari introduix es %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [30 x i8] c"Introdueix el nom de l'usuari\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [45 x i8]
%4 = getelementptr inbounds [45 x i8], [45 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 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 %15, label %10
10: ; preds = %6
%11 = trunc i32 %8 to i8
%12 = getelementptr inbounds [45 x i8], [45 x i8]* %3, i64 0, i64 %7
store i8 %11, i8* %12
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, 44
br i1 %14, label %15, label %6
15: ; preds = %10, %6
%16 = phi i64 [ 44, %10 ], [ %7, %6 ]
%17 = and i64 %16, 4294967295
%18 = getelementptr inbounds [45 x i8], [45 x i8]* %3, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}