#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*/ printf(char *, int);
int *findhigh(char *mark) {
  char *p1;
  p1 = mark;
  static int a[10];
  int i, temp = -1, j = 0;
  while (*mark) {
    if ((*mark) > temp)
      temp = *mark;
    *mark++;
  }
  printf("highest: %d\n", temp);
  for (i = 0; i < 20; i++) {
    if (p1[i] == temp) {
      a[j] = temp;
      j++;
    }
  }
  return a;
}


x86 assembly (clang, -O0):
<findhigh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     116a <findhigh+0x5a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    -0x18(%rbp),%eax
jle    1159 <findhigh+0x49>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1132 <findhigh+0x22>
mov    -0x18(%rbp),%esi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    11cc <findhigh+0xbc>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    -0x18(%rbp),%eax
jne    11b9 <findhigh+0xa9>
mov    -0x18(%rbp),%edx
movslq -0x1c(%rbp),%rcx
lea    0x2e93(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11be <findhigh+0xae>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1180 <findhigh+0x70>
lea    0x2e6d(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findhigh>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%cl
test   %cl,%cl
je     1145 <findhigh+0x35>
lea    0x1(%rbx),%rax
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %cl,%ecx
cmp    %ecx,%ebp
cmovl  %ecx,%ebp
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1130 <findhigh+0x20>
jmp    114a <findhigh+0x3a>
mov    $0xffffffff,%ebp
lea    0xeaf(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %eax,%eax
mov    $0x1,%ecx
lea    0x2eda(%rip),%rdx
jmp    117a <findhigh+0x6a>
nopl   0x0(%rax,%rax,1)
add    $0x2,%rcx
cmp    $0x15,%rcx
je     119d <findhigh+0x8d>
movsbl -0x1(%rbx,%rcx,1),%esi
cmp    %esi,%ebp
jne    118b <findhigh+0x7b>
cltq
mov    %ebp,(%rdx,%rax,4)
add    $0x1,%eax
movsbl (%rbx,%rcx,1),%esi
cmp    %esi,%ebp
jne    1170 <findhigh+0x60>
cltq
mov    %ebp,(%rdx,%rax,4)
add    $0x1,%eax
jmp    1170 <findhigh+0x60>
lea    0x2e9c(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@findhigh.a = internal global [10 x i32] zeroinitializer
@.str = [13 x i8] c"highest: %d\0A\00"
define i32* @findhigh(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
store i8* %7, i8** %3
store i32 -1, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %22, %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = load i32, i32* %5
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
store i32 %21, i32* %5
br label %22
22: ; preds = %18, %12
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %2
%25 = load i8, i8* %23
br label %8
26: ; preds = %8
%27 = load i32, i32* %5
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %27)
store i32 0, i32* %4
br label %29
29: ; preds = %49, %26
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 20
br i1 %31, label %32, label %52
32: ; preds = %29
%33 = load i8*, i8** %3
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = load i32, i32* %5
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %48
41: ; preds = %32
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i32], [10 x i32]* @findhigh.a, i64 0, i64 %44
store i32 %42, i32* %45
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %48
48: ; preds = %41, %32
br label %49
49: ; preds = %48
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %29
52: ; preds = %29
ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @findhigh.a, i64 0, i64 0)
}

LLVM IR (-O2):
@findhigh.a = internal global [10 x i32] zeroinitializer
@.str = [13 x i8] c"highest: %d\0A\00"
define i32* @findhigh(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %12, %4 ], [ %2, %1 ]
%6 = phi i32 [ %10, %4 ], [ -1, %1 ]
%7 = phi i8* [ %11, %4 ], [ %0, %1 ]
%8 = sext i8 %5 to i32
%9 = icmp slt i32 %6, %8
%10 = select i1 %9, i32 %8, i32 %6
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %4
14: ; preds = %4, %1
%15 = phi i32 [ -1, %1 ], [ %10, %4 ]
%16 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %39, %14
%18 = phi i64 [ 0, %14 ], [ %41, %39 ]
%19 = phi i32 [ 0, %14 ], [ %40, %39 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %18
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %15, %22
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = sext i32 %19 to i64
%26 = getelementptr inbounds [10 x i32], [10 x i32]* @findhigh.a, i64 0, i64 %25
store i32 %15, i32* %26
%27 = add nsw i32 %19, 1
br label %28
28: ; preds = %17, %24
%29 = phi i32 [ %27, %24 ], [ %19, %17 ]
%30 = or i64 %18, 1
%31 = getelementptr inbounds i8, i8* %0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %15, %33
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = sext i32 %29 to i64
%37 = getelementptr inbounds [10 x i32], [10 x i32]* @findhigh.a, i64 0, i64 %36
store i32 %15, i32* %37
%38 = add nsw i32 %29, 1
br label %39
39: ; preds = %35, %28
%40 = phi i32 [ %38, %35 ], [ %29, %28 ]
%41 = add nuw nsw i64 %18, 2
%42 = icmp eq i64 %41, 20
br i1 %42, label %43, label %17
43: ; preds = %39
ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @findhigh.a, i64 0, i64 0)
}