#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 *);
int fun(char (*ss)[20]) {
  int i, min, index;
  min = strlen(ss[0]);
  for (i = 0; i < 3; i++) {
    if (min > strlen(ss[i])) {
      min = strlen(ss[i]);
      index = i;
    }
  }
  return index;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1190 <fun+0x80>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jle    117d <fun+0x6d>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <fun+0x72>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112f <fun+0x1f>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jle    1137 <fun+0x27>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0x14(%rbx),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
xor    %r14d,%r14d
cmp    %eax,%ebp
jle    115a <fun+0x4a>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    $0x1,%r14d
add    $0x28,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jle    1178 <fun+0x68>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x2,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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