#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
void cgiMakeIntVarInRange(char *varName, int initialVal, char *title, int width,
                          char *min, char *max) {
  if (width == 0) {
    if (max)
      width = strlen(max) * 10;
    else {
      int sz = initialVal + 1000;
      if (min)
        sz = atoi(min) + 1000;
      width = 10;
      while (sz /= 10)
        width += 10;
    }
  }
  if (width < 65)
    width = 65;
  printf("<INPUT TYPE=TEXT class='inputBox' name=\"%s\" style='width: %dpx' "
         "value=%d",
         varName, width, initialVal);
  printf(" onChange='return validateInt(this,%s,%s);'",
         (min ? min : "\"null\""), (max ? max : "\"null\""));
  if (title)
    printf(" title='%s'", title);
  printf(">\n");
}


x86 assembly (clang, -O0):
<cgiMakeIntVarInRange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11d4 <cgiMakeIntVarInRange+0xa4>
cmpq   $0x0,-0x30(%rbp)
je     1177 <cgiMakeIntVarInRange+0x47>
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
imul   $0xa,%eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    11cf <cgiMakeIntVarInRange+0x9f>
mov    -0xc(%rbp),%eax
add    $0x3e8,%eax
mov    %eax,-0x34(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     119e <cgiMakeIntVarInRange+0x6e>
mov    -0x28(%rbp),%rdi
call   1050 <atoi@plt>
add    $0x3e8,%eax
mov    %eax,-0x34(%rbp)
movl   $0xa,-0x1c(%rbp)
mov    -0x34(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
je     11ca <cgiMakeIntVarInRange+0x9a>
mov    -0x1c(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a5 <cgiMakeIntVarInRange+0x75>
jmp    11cf <cgiMakeIntVarInRange+0x9f>
jmp    11d4 <cgiMakeIntVarInRange+0xa4>
cmpl   $0x41,-0x1c(%rbp)
jge    11e5 <cgiMakeIntVarInRange+0xb5>
movl   $0x41,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     1215 <cgiMakeIntVarInRange+0xe5>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    1225 <cgiMakeIntVarInRange+0xf5>
lea    0xe59(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    1225 <cgiMakeIntVarInRange+0xf5>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1245 <cgiMakeIntVarInRange+0x115>
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1255 <cgiMakeIntVarInRange+0x125>
lea    0xe29(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    1255 <cgiMakeIntVarInRange+0x125>
mov    -0x48(%rbp),%rsi
mov    -0x50(%rbp),%rdx
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     1288 <cgiMakeIntVarInRange+0x158>
mov    -0x18(%rbp),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgiMakeIntVarInRange>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9,%rbx
mov    %r8,%r15
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r12
test   %ecx,%ecx
jne    11c4 <cgiMakeIntVarInRange+0x84>
test   %rbx,%rbx
je     116e <cgiMakeIntVarInRange+0x2e>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %eax,%eax
lea    (%rax,%rax,4),%ecx
jmp    11c4 <cgiMakeIntVarInRange+0x84>
mov    %ebp,%eax
test   %r15,%r15
je     117d <cgiMakeIntVarInRange+0x3d>
mov    %r15,%rdi
call   1060 <atoi@plt>
lea    0x3f1(%rax),%ecx
mov    $0x41,%edx
cmp    $0x13,%ecx
jb     11cf <cgiMakeIntVarInRange+0x8f>
add    $0x3e8,%eax
mov    $0xa,%ecx
nopw   0x0(%rax,%rax,1)
cltq
imul   $0x66666667,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
lea    (%rdx,%rsi,1),%eax
add    $0xa,%ecx
add    %esi,%edx
add    $0x9,%edx
cmp    $0x12,%edx
ja     11a0 <cgiMakeIntVarInRange+0x60>
cmp    $0x42,%ecx
mov    $0x41,%edx
cmovge %ecx,%edx
lea    0xe2a(%rip),%rdi
mov    %r12,%rsi
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15,%r15
lea    0xe89(%rip),%rax
cmove  %rax,%r15
test   %rbx,%rbx
cmove  %rax,%rbx
lea    0xe4b(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14,%r14
je     1221 <cgiMakeIntVarInRange+0xe1>
lea    0xe65(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe60(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [73 x i8] c"<INPUT TYPE=TEXT class='inputBox' name=\22%s\22 style='width: %dpx' value=%d\00"
@.str.1 = [44 x i8] c" onChange='return validateInt(this,%s,%s);'\00"
@.str.2 = [7 x i8] c"\22null\22\00"
@.str.3 = [12 x i8] c" title='%s'\00"
@.str.4 = [3 x i8] c">\0A\00"
define void @cgiMakeIntVarInRange(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%14 = load i32, i32* %10
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %42
16: ; preds = %6
%17 = load i8*, i8** %12
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i8*, i8** %12
%21 = call i32 @strlen(i8* %20)
%22 = mul nsw i32 %21, 10
store i32 %22, i32* %10
br label %41
23: ; preds = %16
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1000
store i32 %25, i32* %13
%26 = load i8*, i8** %11
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i8*, i8** %11
%30 = call i32 @atoi(i8* %29)
%31 = add nsw i32 %30, 1000
store i32 %31, i32* %13
br label %32
32: ; preds = %28, %23
store i32 10, i32* %10
br label %33
33: ; preds = %37, %32
%34 = load i32, i32* %13
%35 = sdiv i32 %34, 10
store i32 %35, i32* %13
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %10
%39 = add nsw i32 %38, 10
store i32 %39, i32* %10
br label %33
40: ; preds = %33
br label %41
41: ; preds = %40, %19
br label %42
42: ; preds = %41, %6
%43 = load i32, i32* %10
%44 = icmp slt i32 %43, 65
br i1 %44, label %45, label %46
45: ; preds = %42
store i32 65, i32* %10
br label %46
46: ; preds = %45, %42
%47 = load i8*, i8** %7
%48 = load i32, i32* %10
%49 = load i32, i32* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i8* %47, i32 %48, i32 %49)
%51 = load i8*, i8** %11
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %55
53: ; preds = %46
%54 = load i8*, i8** %11
br label %56
55: ; preds = %46
br label %56
56: ; preds = %55, %53
%57 = phi i8* [ %54, %53 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %55 ]
%58 = load i8*, i8** %12
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = load i8*, i8** %12
br label %63
62: ; preds = %56
br label %63
63: ; preds = %62, %60
%64 = phi i8* [ %61, %60 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %62 ]
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %57, i8* %64)
%66 = load i8*, i8** %9
%67 = icmp ne i8* %66, null
br i1 %67, label %68, label %71
68: ; preds = %63
%69 = load i8*, i8** %9
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %69)
br label %71
71: ; preds = %68, %63
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [73 x i8] c"<INPUT TYPE=TEXT class='inputBox' name=\22%s\22 style='width: %dpx' value=%d\00"
@.str.1 = [44 x i8] c" onChange='return validateInt(this,%s,%s);'\00"
@.str.2 = [7 x i8] c"\22null\22\00"
@.str.3 = [12 x i8] c" title='%s'\00"
@str = [2 x i8] c">\00"
define void @cgiMakeIntVarInRange(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i8* %5) {
%7 = icmp eq i32 %3, 0
br i1 %7, label %8, label %30
8: ; preds = %6
%9 = icmp eq i8* %5, null
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i32 @strlen(i8* %5)
%12 = mul nsw i32 %11, 10
br label %30
13: ; preds = %8
%14 = icmp eq i8* %4, null
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i32 @atoi(i8* %4)
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %16, %15 ], [ %1, %13 ]
%19 = add i32 %18, 1009
%20 = icmp ult i32 %19, 19
br i1 %20, label %34, label %21
21: ; preds = %17
%22 = add nsw i32 %18, 1000
br label %23
23: ; preds = %21, %23
%24 = phi i32 [ %26, %23 ], [ %22, %21 ]
%25 = phi i32 [ %27, %23 ], [ 10, %21 ]
%26 = sdiv i32 %24, 10
%27 = add nuw nsw i32 %25, 10
%28 = add nsw i32 %26, 9
%29 = icmp ult i32 %28, 19
br i1 %29, label %30, label %23
30: ; preds = %23, %10, %6
%31 = phi i32 [ %12, %10 ], [ %3, %6 ], [ %27, %23 ]
%32 = icmp sgt i32 %31, 65
%33 = select i1 %32, i32 %31, i32 65
br label %34
34: ; preds = %30, %17
%35 = phi i32 [ 65, %17 ], [ %33, %30 ]
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %35, i32 %1)
%37 = icmp eq i8* %4, null
%38 = select i1 %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %4
%39 = icmp eq i8* %5, null
%40 = select i1 %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %5
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %38, i8* %40)
%42 = icmp eq i8* %2, null
br i1 %42, label %45, label %43
43: ; preds = %34
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %2)
br label %45
45: ; preds = %43, %34
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}