#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 llist {
  int dummy;
};

/* Variables and functions */
char *firstitem(struct llist *);
char *nextitem(struct llist *);
double stringwidth(char *, double, int);
double maxstrwidth(struct llist *strings, double ptsize, int fontno) {
  double width, max;
  char *str;
  max = 0.0;
  str = firstitem(strings);
  while (str != NULL) {
    width = stringwidth(str, ptsize, fontno);
    if (width > max) {
      max = width;
    };
    str = nextitem(strings);
  };
  return (max);
}


x86 assembly (clang, -O0):
<maxstrwidth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <firstitem@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11a6 <maxstrwidth+0x76>
mov    -0x30(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%esi
call   1040 <stringwidth@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1194 <maxstrwidth+0x64>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <nextitem@plt>
mov    %rax,-0x30(%rbp)
jmp    1159 <maxstrwidth+0x29>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maxstrwidth>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
call   1030 <firstitem@plt>
test   %rax,%rax
je     118a <maxstrwidth+0x5a>
xorps  %xmm1,%xmm1
xchg   %ax,%ax
movsd  %xmm1,0x8(%rsp)
mov    %rax,%rdi
movsd  0x10(%rsp),%xmm0
mov    %ebp,%esi
call   1040 <stringwidth@plt>
maxsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1050 <nextitem@plt>
movsd  0x8(%rsp),%xmm0
movaps %xmm0,%xmm1
test   %rax,%rax
jne    1150 <maxstrwidth+0x20>
jmp    118d <maxstrwidth+0x5d>
xorps  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.llist = type { i32 }
define double @maxstrwidth(%struct.llist* %0, double %1, i32 %2) {
%4 = alloca %struct.llist*
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i8*
store %struct.llist* %0, %struct.llist** %4
store double %1, double* %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %8
%10 = load %struct.llist*, %struct.llist** %4
%11 = call i8* @firstitem(%struct.llist* %10)
store i8* %11, i8** %9
br label %12
12: ; preds = %25, %3
%13 = load i8*, i8** %9
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i8*, i8** %9
%17 = load double, double* %5
%18 = load i32, i32* %6
%19 = call double @stringwidth(i8* %16, double %17, i32 %18)
store double %19, double* %7
%20 = load double, double* %7
%21 = load double, double* %8
%22 = fcmp ogt double %20, %21
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = load double, double* %7
store double %24, double* %8
br label %25
25: ; preds = %23, %15
%26 = load %struct.llist*, %struct.llist** %4
%27 = call i8* @nextitem(%struct.llist* %26)
store i8* %27, i8** %9
br label %12
28: ; preds = %12
%29 = load double, double* %8
ret double %29
}

LLVM IR (-O2):
%struct.llist = type { i32 }
define double @maxstrwidth(%struct.llist* %0, double %1, i32 %2) {
%4 = tail call i8* @firstitem(%struct.llist* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3, %6
%7 = phi i8* [ %12, %6 ], [ %4, %3 ]
%8 = phi double [ %11, %6 ], [ 0.000000e+00, %3 ]
%9 = tail call double @stringwidth(i8* %7, double %1, i32 %2)
%10 = fcmp ogt double %9, %8
%11 = select i1 %10, double %9, double %8
%12 = tail call i8* @nextitem(%struct.llist* %0)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %6
14: ; preds = %6, %3
%15 = phi double [ 0.000000e+00, %3 ], [ %11, %6 ]
ret double %15
}