#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*/ OutputByte(unsigned char);
scalar_t__ strlen(char *);
scalar_t__ toupper(char);
void OutputName(char *name) {
  int k;
  OutputByte((unsigned char)strlen(name));
  for (k = 0; name[k] != 0; k++)
    OutputByte((unsigned char)toupper(name[k]));
}


x86 assembly (clang, -O0):
<OutputName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
movzbl %al,%edi
call   1050 <OutputByte@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1190 <OutputName+0x60>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
movzbl %al,%edi
call   1050 <OutputByte@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <OutputName+0x24>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OutputName>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
movzbl %al,%edi
call   1050 <OutputByte@plt>
mov    (%rbx),%al
test   %al,%al
je     116b <OutputName+0x3b>
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <toupper@plt>
movzbl %al,%edi
call   1050 <OutputByte@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <OutputName+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define void @OutputName(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strlen(i8* %4)
%6 = trunc i64 %5 to i8
%7 = call i32 @OutputByte(i8 zeroext %6)
store i32 0, i32* %3
br label %8
8: ; preds = %25, %1
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %8
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call i64 @toupper(i8 signext %21)
%23 = trunc i64 %22 to i8
%24 = call i32 @OutputByte(i8 zeroext %23)
br label %25
25: ; preds = %16
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %8
28: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @OutputName(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i8
%4 = tail call i32 @OutputByte(i8 zeroext %3)
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %1, %7
%8 = phi i64 [ %13, %7 ], [ 0, %1 ]
%9 = phi i8 [ %15, %7 ], [ %5, %1 ]
%10 = tail call i64 @toupper(i8 signext %9)
%11 = trunc i64 %10 to i8
%12 = tail call i32 @OutputByte(i8 zeroext %11)
%13 = add nuw i64 %8, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %7, %1
ret void
}