#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 strlen(char *);
void ReverseLarger(char *vals, int *direct, int lm) {
  for (int i = 0; i < strlen(vals); ++i)
    if (vals[i] > vals[lm])
      direct[i] *= -1;
}


x86 assembly (clang, -O0):
<ReverseLarger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1188 <ReverseLarger+0x78>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jle    1175 <ReverseLarger+0x65>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0xffffffff,(%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
jmp    117a <ReverseLarger+0x6a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <ReverseLarger+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReverseLarger>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1153 <ReverseLarger+0x43>
movslq %ebp,%r15
xor    %ebp,%ebp
jmp    1143 <ReverseLarger+0x33>
nop
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1153 <ReverseLarger+0x43>
movzbl (%rbx,%rbp,1),%eax
cmp    (%rbx,%r15,1),%al
jle    1130 <ReverseLarger+0x20>
negl   (%r14,%rbp,4)
jmp    1130 <ReverseLarger+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @ReverseLarger(i8* %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
br label %10
9: ; preds = %20, %3
ret void
10: ; preds = %6, %20
%11 = phi i64 [ 0, %6 ], [ %21, %20 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = load i8, i8* %8
%15 = icmp sgt i8 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = getelementptr inbounds i32, i32* %1, i64 %11
%18 = load i32, i32* %17
%19 = sub nsw i32 0, %18
store i32 %19, i32* %17
br label %20
20: ; preds = %10, %16
%21 = add nuw nsw i64 %11, 1
%22 = tail call i32 @strlen(i8* %0)
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %10, label %9
}