#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mytoupper(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
int main() {
  char a[32];
  fgets(a, sizeof(a), stdin);
  if (!a[sizeof(a) - 1]) {
    printf("Greater than %lu. Thus, null terminated\n", sizeof(a));
  }
  mytoupper(a);
  puts(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
mov    0x2e8e(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1050 <fgets@plt>
cmpb   $0x0,-0x11(%rbp)
jne    1181 <main+0x41>
lea    0xe89(%rip),%rdi
mov    $0x20,%esi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1060 <mytoupper@plt>
lea    -0x30(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0x2e9c(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x20,%esi
call   1050 <fgets@plt>
cmpb   $0x0,0x1f(%rsp)
jne    1173 <main+0x33>
lea    0xe97(%rip),%rdi
mov    $0x20,%esi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <mytoupper@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [41 x i8] c"Greater than %lu. Thus, null terminated\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %3, i32 32, i32 %4)
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 31
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 32)
br label %11
11: ; preds = %9, %0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%13 = call i32 @mytoupper(i8* %12)
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%15 = call i32 @puts(i8* %14)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [41 x i8] c"Greater than %lu. Thus, null terminated\0A\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 32, i32 %3)
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 31
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 32)
br label %10
10: ; preds = %8, %0
%11 = call i32 @mytoupper(i8* %2)
%12 = call i32 @puts(i8* %2)
ret i32 0
}