#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*/ diagnostics(int, char *, char *, ...);
int /*<<< orphan*/ free(char *);
double getStringDimension(char *);
char *keyvalue_pair(char *, char **, char **);
char *my_strdup(char *);
scalar_t__ strstr(char *, char *);
void HandlePsfigOptions(char *opt, char **filename, double *h, double *w,
                        double *s) {
  *s = 1.0;
  *h = 0.0;
  *w = 0.0;
  *filename = NULL;
  diagnostics(4, "HandlePsfigOptions <%s>", opt);
  while (opt) {
    char *key, *value;
    opt = keyvalue_pair(opt, &key, &value);
    if (key) {
      diagnostics(5, "psfig key=%s, value=%s", key, value);
      if (strstr(key, "figure"))
        *filename = my_strdup(value);
      else if (strstr(key, "height")) {
        *h = getStringDimension(value);
      } else if (strstr(key, "width")) {
        *w = getStringDimension(value);
      }
      free(key);
    }
    if (value)
      free(value);
  }
}


x86 assembly (clang, -O0):
<HandlePsfigOptions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsd  0xe78(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdx
mov    $0x4,%edi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1050 <diagnostics@plt>
cmpq   $0x0,-0x8(%rbp)
je     12c3 <HandlePsfigOptions+0x163>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1040 <keyvalue_pair@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12aa <HandlePsfigOptions+0x14a>
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    $0x5,%edi
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1050 <diagnostics@plt>
mov    -0x30(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     123c <HandlePsfigOptions+0xdc>
mov    -0x38(%rbp),%rdi
call   1060 <my_strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    12a1 <HandlePsfigOptions+0x141>
mov    -0x30(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     126c <HandlePsfigOptions+0x10c>
mov    -0x38(%rbp),%rdi
call   1070 <getStringDimension@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    129c <HandlePsfigOptions+0x13c>
mov    -0x30(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1297 <HandlePsfigOptions+0x137>
mov    -0x38(%rbp),%rdi
call   1070 <getStringDimension@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    129c <HandlePsfigOptions+0x13c>
jmp    12a1 <HandlePsfigOptions+0x141>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x38(%rbp)
je     12be <HandlePsfigOptions+0x15e>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
jmp    11c4 <HandlePsfigOptions+0x64>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HandlePsfigOptions>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r12
mov    %rdi,%rbx
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r8)
mov    %rdx,0x20(%rsp)
movq   $0x0,(%rdx)
mov    %rcx,0x18(%rsp)
movq   $0x0,(%rcx)
movq   $0x0,(%rsi)
lea    0xe59(%rip),%rsi
mov    $0x4,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <diagnostics@plt>
test   %rbx,%rbx
je     12b2 <HandlePsfigOptions+0x152>
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%rbp
lea    0xe48(%rip),%r14
lea    0xe58(%rip),%r15
jmp    11e9 <HandlePsfigOptions+0x89>
nopl   0x0(%rax)
test   %rbx,%rbx
je     12b2 <HandlePsfigOptions+0x152>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1040 <keyvalue_pair@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rdx
test   %rdx,%rdx
je     129a <HandlePsfigOptions+0x13a>
mov    0x8(%rsp),%rcx
mov    $0x5,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <diagnostics@plt>
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     1240 <HandlePsfigOptions+0xe0>
mov    0x8(%rsp),%rdi
call   1060 <my_strdup@plt>
mov    %rax,(%r12)
jmp    1290 <HandlePsfigOptions+0x130>
xchg   %ax,%ax
mov    0x10(%rsp),%rdi
lea    0xdea(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     1267 <HandlePsfigOptions+0x107>
mov    0x8(%rsp),%rdi
call   1070 <getStringDimension@plt>
mov    0x20(%rsp),%rax
jmp    128c <HandlePsfigOptions+0x12c>
mov    0x10(%rsp),%rdi
lea    0xdca(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     1290 <HandlePsfigOptions+0x130>
mov    0x8(%rsp),%rdi
call   1070 <getStringDimension@plt>
mov    0x18(%rsp),%rax
movsd  %xmm0,(%rax)
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     11e0 <HandlePsfigOptions+0x80>
call   1030 <free@plt>
jmp    11e0 <HandlePsfigOptions+0x80>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"HandlePsfigOptions <%s>\00"
@.str.1 = [23 x i8] c"psfig key=%s, value=%s\00"
@.str.2 = [7 x i8] c"figure\00"
@.str.3 = [7 x i8] c"height\00"
@.str.4 = [6 x i8] c"width\00"
define void @HandlePsfigOptions(i8* %0, i8** %1, double* %2, double* %3, double* %4) {
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %6
store i8** %1, i8*** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%13 = load double*, double** %10
store double 1.000000e+00, double* %13
%14 = load double*, double** %8
store double 0.000000e+00, double* %14
%15 = load double*, double** %9
store double 0.000000e+00, double* %15
%16 = load i8**, i8*** %7
store i8* null, i8** %16
%17 = load i8*, i8** %6
%18 = call i32 (i32, i8*, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %65, %5
%20 = load i8*, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %66
22: ; preds = %19
%23 = load i8*, i8** %6
%24 = call i8* @keyvalue_pair(i8* %23, i8** %11, i8** %12)
store i8* %24, i8** %6
%25 = load i8*, i8** %11
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %59
27: ; preds = %22
%28 = load i8*, i8** %11
%29 = load i8*, i8** %12
%30 = call i32 (i32, i8*, i8*, ...) @diagnostics(i32 5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %29)
%31 = load i8*, i8** %11
%32 = call i64 @strstr(i8* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %27
%35 = load i8*, i8** %12
%36 = call i8* @my_strdup(i8* %35)
%37 = load i8**, i8*** %7
store i8* %36, i8** %37
br label %56
38: ; preds = %27
%39 = load i8*, i8** %11
%40 = call i64 @strstr(i8* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i8*, i8** %12
%44 = call double @getStringDimension(i8* %43)
%45 = load double*, double** %8
store double %44, double* %45
br label %55
46: ; preds = %38
%47 = load i8*, i8** %11
%48 = call i64 @strstr(i8* %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = load i8*, i8** %12
%52 = call double @getStringDimension(i8* %51)
%53 = load double*, double** %9
store double %52, double* %53
br label %54
54: ; preds = %50, %46
br label %55
55: ; preds = %54, %42
br label %56
56: ; preds = %55, %34
%57 = load i8*, i8** %11
%58 = call i32 @free(i8* %57)
br label %59
59: ; preds = %56, %22
%60 = load i8*, i8** %12
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i8*, i8** %12
%64 = call i32 @free(i8* %63)
br label %65
65: ; preds = %62, %59
br label %19
66: ; preds = %19
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"HandlePsfigOptions <%s>\00"
@.str.1 = [23 x i8] c"psfig key=%s, value=%s\00"
@.str.2 = [7 x i8] c"figure\00"
@.str.3 = [7 x i8] c"height\00"
@.str.4 = [6 x i8] c"width\00"
define void @HandlePsfigOptions(i8* %0, i8** nocapture writeonly %1, double* nocapture writeonly %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = alloca i8*
%7 = alloca i8*
store double 1.000000e+00, double* %4
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
store i8* null, i8** %1
%8 = tail call i32 (i32, i8*, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = icmp eq i8* %0, null
br i1 %9, label %51, label %10
10: ; preds = %5
%11 = bitcast i8** %6 to i8*
%12 = bitcast i8** %7 to i8*
br label %13
13: ; preds = %10, %49
%14 = phi i8* [ %0, %10 ], [ %15, %49 ]
%15 = call i8* @keyvalue_pair(i8* %14, i8** %6, i8** %7)
%16 = load i8*, i8** %6
%17 = icmp eq i8* %16, null
br i1 %17, label %44, label %18
18: ; preds = %13
%19 = load i8*, i8** %7
%20 = call i32 (i32, i8*, i8*, ...) @diagnostics(i32 5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %19)
%21 = load i8*, i8** %6
%22 = call i64 @strstr(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %18
%25 = load i8*, i8** %7
%26 = call i8* @my_strdup(i8* %25)
store i8* %26, i8** %1
br label %41
27: ; preds = %18
%28 = load i8*, i8** %6
%29 = call i64 @strstr(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = load i8*, i8** %7
%33 = call double @getStringDimension(i8* %32)
store double %33, double* %2
br label %41
34: ; preds = %27
%35 = load i8*, i8** %6
%36 = call i64 @strstr(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %34
%39 = load i8*, i8** %7
%40 = call double @getStringDimension(i8* %39)
store double %40, double* %3
br label %41
41: ; preds = %31, %38, %34, %24
%42 = load i8*, i8** %6
%43 = call i32 @free(i8* %42)
br label %44
44: ; preds = %41, %13
%45 = load i8*, i8** %7
%46 = icmp eq i8* %45, null
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = call i32 @free(i8* %45)
br label %49
49: ; preds = %47, %44
%50 = icmp eq i8* %15, null
br i1 %50, label %51, label %13
51: ; preds = %49, %5
ret void
}