#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 toupper(char);
void mytoupper(char a[][10], int row) {
  int i = 0;
  int j = 0;
  for (i = 0; i < row; i++) {
    for (j = 0; (a[i][j] = toupper(a[i][j])); j++)
      ;
  }
}


x86 assembly (clang, -O0):
<mytoupper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a7 <mytoupper+0x97>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0xa,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
imul   $0xa,%rdx,%rdx
add    %rdx,%rcx
movslq -0x14(%rbp),%rdx
mov    %al,(%rcx,%rdx,1)
cmp    $0x0,%al
je     1194 <mytoupper+0x84>
jmp    1186 <mytoupper+0x76>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <mytoupper+0x37>
jmp    1199 <mytoupper+0x89>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <mytoupper+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mytoupper>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    115f <mytoupper+0x4f>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%rbx),%edi
call   1030 <toupper@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
test   %al,%al
jne    1140 <mytoupper+0x30>
add    $0x1,%r12
add    $0xa,%r15
cmp    %r14,%r12
jne    1130 <mytoupper+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @mytoupper([10 x i8]* %0, i32 %1) {
%3 = alloca [10 x i8]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store [10 x i8]* %0, [10 x i8]** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %35, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %38
11: ; preds = %7
store i32 0, i32* %6
br label %12
12: ; preds = %31, %11
%13 = load [10 x i8]*, [10 x i8]** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 %15
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call signext i8 @toupper(i8 signext %20)
%22 = load [10 x i8]*, [10 x i8]** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 %24
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %25, i64 0, i64 %27
store i8 %21, i8* %28
%29 = icmp ne i8 %21, 0
br i1 %29, label %30, label %34
30: ; preds = %12
br label %31
31: ; preds = %30
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %12
34: ; preds = %12
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %7
38: ; preds = %7
ret void
}

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