#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 getchar();
int /*<<< orphan*/ printf(char *);
char *strccat(char *, int /*<<< orphan*/);
char *strmalloc();
int /*<<< orphan*/ toupper(char);
char *strget(char *str) {
  char c = 0;
  str = strmalloc();
  printf(">");
  while (c != '\n') {
    c = getchar();
    if (c != '\n')
      str = strccat(str, toupper(c));
  }
  return str;
}


x86 assembly (clang, -O0):
<strget>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    $0x0,%al
call   1030 <strmalloc@plt>
mov    %rax,-0x8(%rbp)
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     11c0 <strget+0x70>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     11bb <strget+0x6b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movsbl -0x9(%rbp),%edi
call   1040 <toupper@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1060 <strccat@plt>
mov    %rax,-0x8(%rbp)
jmp    1177 <strget+0x27>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strget>:
push   %rbx
xor    %eax,%eax
call   1040 <strmalloc@plt>
mov    %rax,%rbx
mov    $0x3e,%edi
call   1030 <putchar@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
je     1192 <strget+0x42>
movsbl %al,%edi
call   1050 <toupper@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <strccat@plt>
mov    %rax,%rbx
jmp    1170 <strget+0x20>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c">\00"
define i8* @strget(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
store i8 0, i8* %3
%4 = call i8* (...) @strmalloc()
store i8* %4, i8** %2
%5 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %20, %1
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %21
10: ; preds = %6
%11 = call signext i8 (...) @getchar()
store i8 %11, i8* %3
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = load i8, i8* %3
%18 = call i32 @toupper(i8 signext %17)
%19 = call i8* @strccat(i8* %16, i32 %18)
store i8* %19, i8** %2
br label %20
20: ; preds = %15, %10
br label %6
21: ; preds = %6
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
define i8* @strget(i8* nocapture readnone %0) {
%2 = tail call i8* (...) @strmalloc()
%3 = tail call i32 @putchar(i32 62)
%4 = tail call signext i8 (...) @getchar()
%5 = icmp eq i8 %4, 10
br i1 %5, label %13, label %6
6: ; preds = %1, %6
%7 = phi i8 [ %11, %6 ], [ %4, %1 ]
%8 = phi i8* [ %10, %6 ], [ %2, %1 ]
%9 = tail call i32 @toupper(i8 signext %7)
%10 = tail call i8* @strccat(i8* %8, i32 %9)
%11 = tail call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %6
13: ; preds = %6, %1
%14 = phi i8* [ %2, %1 ], [ %10, %6 ]
ret i8* %14
}