#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 */
scalar_t__ _toupper(unsigned char);
scalar_t__ islower(unsigned char);
char *_strupr(char *string) {
  unsigned char *p;
  for (p = (unsigned char *)string; *p != 0; ++p)
    if (islower(*p))
      *p = (unsigned char)_toupper(*p);
  return string;
}


x86 assembly (clang, -O0):
<_strupr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     1184 <_strupr+0x64>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     116e <_strupr+0x4e>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1040 <_toupper@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    1173 <_strupr+0x53>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <_strupr+0x14>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_strupr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     1165 <_strupr+0x45>
mov    %r14,%rbx
jmp    114c <_strupr+0x2c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1165 <_strupr+0x45>
movzbl %al,%edi
call   1030 <islower@plt>
test   %rax,%rax
je     1140 <_strupr+0x20>
movzbl (%rbx),%edi
call   1040 <_toupper@plt>
mov    %al,(%rbx)
jmp    1140 <_strupr+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @_strupr(i8* returned %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %13
%5 = phi i8 [ %15, %13 ], [ %2, %1 ]
%6 = phi i8* [ %14, %13 ], [ %0, %1 ]
%7 = tail call i64 @islower(i8 zeroext %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = load i8, i8* %6
%11 = tail call i64 @_toupper(i8 zeroext %10)
%12 = trunc i64 %11 to i8
store i8 %12, i8* %6
br label %13
13: ; preds = %4, %9
%14 = getelementptr inbounds i8, i8* %6, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %13, %1
ret i8* %0
}