#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 INT_MAX;
int /*<<< orphan*/ pm_error(char *, ...);
int /*<<< orphan*/ pm_interpret_uint(char const *const, unsigned int *,
                                     char const **);
int /*<<< orphan*/ pm_strfree(char const *);
unsigned int pm_parse_width(const char *const arg) {
  unsigned int width;
  const char *error;
  pm_interpret_uint(arg, &width, &error);
  if (error) {
    pm_error("'%s' is invalid as an image width.  %s", arg, error);
    pm_strfree(error);
  } else {
    if (width > INT_MAX - 10)
      pm_error("Width %u is too large for computations.", width);
    if (width == 0)
      pm_error("Width argument must be a positive number.  You "
               "specified 0.");
  }
  return width;
}


x86 assembly (clang, -O0):
<pm_parse_width>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <pm_interpret_uint@plt>
cmpq   $0x0,-0x18(%rbp)
je     117c <pm_parse_width+0x4c>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1050 <pm_error@plt>
mov    -0x18(%rbp),%rdi
call   1040 <pm_strfree@plt>
jmp    11c1 <pm_parse_width+0x91>
mov    -0xc(%rbp),%eax
mov    0x2e62(%rip),%rcx
mov    (%rcx),%ecx
sub    $0xa,%ecx
cmp    %ecx,%eax
jbe    11a4 <pm_parse_width+0x74>
mov    -0xc(%rbp),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <pm_error@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11bc <pm_parse_width+0x8c>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <pm_error@plt>
jmp    11c1 <pm_parse_width+0x91>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pm_parse_width>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <pm_interpret_uint@plt>
mov    0x8(%rsp),%rdx
test   %rdx,%rdx
je     116e <pm_parse_width+0x3e>
lea    0xea8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <pm_error@plt>
mov    0x8(%rsp),%rdi
call   1040 <pm_strfree@plt>
jmp    11a6 <pm_parse_width+0x76>
mov    0x4(%rsp),%esi
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
add    $0xfffffff6,%eax
cmp    %eax,%esi
jbe    1194 <pm_parse_width+0x64>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1050 <pm_error@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jne    11a6 <pm_parse_width+0x76>
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1050 <pm_error@plt>
mov    0x4(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"'%s' is invalid as an image width. %s\00"
@INT_MAX = global i32 0
@.str.1 = [40 x i8] c"Width %u is too large for computations.\00"
@.str.2 = [60 x i8] c"Width argument must be a positive number. You specified 0.\00"
define i32 @pm_parse_width(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @pm_interpret_uint(i8* %5, i32* %3, i8** %4)
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = load i8*, i8** %4
%12 = call i32 (i8*, ...) @pm_error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i8*, i8** %4
%14 = call i32 @pm_strfree(i8* %13)
br label %29
15: ; preds = %1
%16 = load i32, i32* %3
%17 = load i32, i32* @INT_MAX
%18 = sub nsw i32 %17, 10
%19 = icmp ugt i32 %16, %18
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @pm_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %15
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i8*, ...) @pm_error(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
br label %29
29: ; preds = %28, %9
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [39 x i8] c"'%s' is invalid as an image width. %s\00"
@INT_MAX = global i32 0
@.str.1 = [40 x i8] c"Width %u is too large for computations.\00"
@.str.2 = [60 x i8] c"Width argument must be a positive number. You specified 0.\00"
define i32 @pm_parse_width(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = bitcast i32* %2 to i8*
%5 = bitcast i8** %3 to i8*
%6 = call i32 @pm_interpret_uint(i8* %0, i32* %2, i8** %3)
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %13, label %9
9: ; preds = %1
%10 = call i32 (i8*, ...) @pm_error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %7)
%11 = load i8*, i8** %3
%12 = call i32 @pm_strfree(i8* %11)
br label %26
13: ; preds = %1
%14 = load i32, i32* %2
%15 = load i32, i32* @INT_MAX
%16 = add nsw i32 %15, -10
%17 = icmp ugt i32 %14, %16
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = call i32 (i8*, ...) @pm_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%20 = load i32, i32* %2
br label %21
21: ; preds = %18, %13
%22 = phi i32 [ %20, %18 ], [ %14, %13 ]
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (i8*, ...) @pm_error(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %21, %24, %9
%27 = load i32, i32* %2
ret i32 %27
}