#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 */
struct tinyrl {
  int dummy;
};

/* Variables and functions */
size_t strlen(char *const);
size_t tinyrl__get_width(struct tinyrl *);
int /*<<< orphan*/ tinyrl_crlf(struct tinyrl *);
int /*<<< orphan*/ tinyrl_printf(struct tinyrl *, char *, size_t, char *const);
void tinyrl_display_matches(struct tinyrl *this, char *const *matches) {
  char *const *m;
  size_t max;
  size_t c, cols;
  max = 0;
  for (m = matches; *m; m++) {
    size_t size = strlen(*m);
    if (max < size)
      max = size;
  }
  cols = tinyrl__get_width(this) / (max + 1);
  m = matches;
  for (m = matches; *m;) {
    for (c = 0; c < cols && *m; c++, m++)
      tinyrl_printf(this, "%-*s ", max, *m);
    tinyrl_crlf(this);
  }
}


x86 assembly (clang, -O0):
<tinyrl_display_matches>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11aa <tinyrl_display_matches+0x6a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    1194 <tinyrl_display_matches+0x54>
mov    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1199 <tinyrl_display_matches+0x59>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1160 <tinyrl_display_matches+0x20>
mov    -0x8(%rbp),%rdi
call   1030 <tinyrl__get_width@plt>
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1261 <tinyrl_display_matches+0x121>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmp    -0x30(%rbp),%rcx
mov    %al,-0x39(%rbp)
jae    120b <tinyrl_display_matches+0xcb>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    121b <tinyrl_display_matches+0xdb>
jmp    1253 <tinyrl_display_matches+0x113>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
lea    0xdcf(%rip),%rsi
call   1060 <tinyrl_printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    11ea <tinyrl_display_matches+0xaa>
mov    -0x8(%rbp),%rdi
call   1050 <tinyrl_crlf@plt>
jmp    11d4 <tinyrl_display_matches+0x94>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tinyrl_display_matches>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%rdi
test   %rdi,%rdi
je     118b <tinyrl_display_matches+0x4b>
lea    0x8(%rbx),%rbp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1040 <strlen@plt>
cmp    %rax,%r15
cmovb  %rax,%r15
mov    0x0(%rbp),%rdi
add    $0x8,%rbp
test   %rdi,%rdi
jne    1170 <tinyrl_display_matches+0x30>
jmp    118e <tinyrl_display_matches+0x4e>
xor    %r15d,%r15d
mov    %r14,%rdi
call   1030 <tinyrl__get_width@plt>
mov    (%rbx),%rcx
test   %rcx,%rcx
je     1248 <tinyrl_display_matches+0x108>
mov    %rax,%rsi
lea    0x1(%r15),%rdi
or     %rdi,%rax
shr    $0x20,%rax
je     11bc <tinyrl_display_matches+0x7c>
mov    %rsi,%rax
xor    %edx,%edx
div    %rdi
jmp    11c2 <tinyrl_display_matches+0x82>
mov    %esi,%eax
xor    %edx,%edx
div    %edi
cmp    $0x2,%rax
mov    $0x1,%r12d
cmovae %rax,%r12
lea    0xe29(%rip),%r13
mov    %rsi,0x10(%rsp)
mov    %rdi,0x8(%rsp)
jmp    120a <tinyrl_display_matches+0xca>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1050 <tinyrl_crlf@plt>
mov    (%rbx),%rcx
test   %rcx,%rcx
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdi
je     1248 <tinyrl_display_matches+0x108>
cmp    %rsi,%rdi
ja     11f0 <tinyrl_display_matches+0xb0>
test   %rcx,%rcx
je     11f0 <tinyrl_display_matches+0xb0>
add    $0x8,%rbx
mov    $0x1,%ebp
mov    %rbx,%rax
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1060 <tinyrl_printf@plt>
cmp    %r12,%rbp
je     11f0 <tinyrl_display_matches+0xb0>
mov    (%rbx),%rcx
add    $0x1,%rbp
lea    0x8(%rbx),%rax
test   %rcx,%rcx
jne    1220 <tinyrl_display_matches+0xe0>
jmp    11f0 <tinyrl_display_matches+0xb0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tinyrl = type { i32 }
@.str = [6 x i8] c"%-*s \00"
define void @tinyrl_display_matches(%struct.tinyrl* %0, i8** %1) {
%3 = alloca %struct.tinyrl*
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store %struct.tinyrl* %0, %struct.tinyrl** %3
store i8** %1, i8*** %4
store i64 0, i64* %6
%10 = load i8**, i8*** %4
store i8** %10, i8*** %5
br label %11
11: ; preds = %25, %2
%12 = load i8**, i8*** %5
%13 = load i8*, i8** %12
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %28
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = load i8*, i8** %16
%18 = call i64 @strlen(i8* %17)
store i64 %18, i64* %9
%19 = load i64, i64* %6
%20 = load i64, i64* %9
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = load i64, i64* %9
store i64 %23, i64* %6
br label %24
24: ; preds = %22, %15
br label %25
25: ; preds = %24
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i32 1
store i8** %27, i8*** %5
br label %11
28: ; preds = %11
%29 = load %struct.tinyrl*, %struct.tinyrl** %3
%30 = call i64 @tinyrl__get_width(%struct.tinyrl* %29)
%31 = load i64, i64* %6
%32 = add i64 %31, 1
%33 = udiv i64 %30, %32
store i64 %33, i64* %8
%34 = load i8**, i8*** %4
store i8** %34, i8*** %5
%35 = load i8**, i8*** %4
store i8** %35, i8*** %5
br label %36
36: ; preds = %62, %28
%37 = load i8**, i8*** %5
%38 = load i8*, i8** %37
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %65
40: ; preds = %36
store i64 0, i64* %7
br label %41
41: ; preds = %57, %40
%42 = load i64, i64* %7
%43 = load i64, i64* %8
%44 = icmp ult i64 %42, %43
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = load i8**, i8*** %5
%47 = load i8*, i8** %46
%48 = icmp ne i8* %47, null
br label %49
49: ; preds = %45, %41
%50 = phi i1 [ false, %41 ], [ %48, %45 ]
br i1 %50, label %51, label %62
51: ; preds = %49
%52 = load %struct.tinyrl*, %struct.tinyrl** %3
%53 = load i64, i64* %6
%54 = load i8**, i8*** %5
%55 = load i8*, i8** %54
%56 = call i32 @tinyrl_printf(%struct.tinyrl* %52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %53, i8* %55)
br label %57
57: ; preds = %51
%58 = load i64, i64* %7
%59 = add i64 %58, 1
store i64 %59, i64* %7
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i32 1
store i8** %61, i8*** %5
br label %41
62: ; preds = %49
%63 = load %struct.tinyrl*, %struct.tinyrl** %3
%64 = call i32 @tinyrl_crlf(%struct.tinyrl* %63)
br label %36
65: ; preds = %36
ret void
}

LLVM IR (-O2):
%struct.tinyrl = type { i32 }
@.str = [6 x i8] c"%-*s \00"
define void @tinyrl_display_matches(%struct.tinyrl* %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %15, label %5
5: ; preds = %2, %5
%6 = phi i8* [ %13, %5 ], [ %3, %2 ]
%7 = phi i8** [ %12, %5 ], [ %1, %2 ]
%8 = phi i64 [ %11, %5 ], [ 0, %2 ]
%9 = tail call i64 @strlen(i8* %6)
%10 = icmp ult i64 %8, %9
%11 = select i1 %10, i64 %9, i64 %8
%12 = getelementptr inbounds i8*, i8** %7, i64 1
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %5
15: ; preds = %5, %2
%16 = phi i64 [ 0, %2 ], [ %11, %5 ]
%17 = tail call i64 @tinyrl__get_width(%struct.tinyrl* %0)
%18 = add i64 %16, 1
%19 = load i8*, i8** %1
%20 = icmp eq i8* %19, null
br i1 %20, label %46, label %21
21: ; preds = %15
%22 = udiv i64 %17, %18
%23 = icmp ugt i64 %18, %17
%24 = call i64 @llvm.umax.i64(i64 %22, i64 1)
br label %25
25: ; preds = %21, %41
%26 = phi i8* [ %19, %21 ], [ %44, %41 ]
%27 = phi i8** [ %1, %21 ], [ %42, %41 ]
%28 = icmp eq i8* %26, null
%29 = select i1 %23, i1 true, i1 %28
br i1 %29, label %41, label %30
30: ; preds = %25, %38
%31 = phi i64 [ %35, %38 ], [ 0, %25 ]
%32 = phi i8** [ %36, %38 ], [ %27, %25 ]
%33 = phi i8* [ %39, %38 ], [ %26, %25 ]
%34 = tail call i32 @tinyrl_printf(%struct.tinyrl* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %16, i8* %33)
%35 = add nuw i64 %31, 1
%36 = getelementptr inbounds i8*, i8** %32, i64 1
%37 = icmp eq i64 %35, %24
br i1 %37, label %41, label %38
38: ; preds = %30
%39 = load i8*, i8** %36
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %30
41: ; preds = %30, %38, %25
%42 = phi i8** [ %27, %25 ], [ %36, %38 ], [ %36, %30 ]
%43 = tail call i32 @tinyrl_crlf(%struct.tinyrl* %0)
%44 = load i8*, i8** %42
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %25
46: ; preds = %41, %15
ret void
}