#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 EINVAL;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ perror(char *);
int sscanf(int /*<<< orphan*/, char *, int *, int *, int *);
int /*<<< orphan*/ stderr;
int parse_resolution(char option, char *arg_str, int *height, int *width,
                     int *depth) {
  int rc;
  rc = sscanf(optarg, "%dx%dx%d\n", height, width, depth);
  if (rc < 0) {
    perror("Unable to parse argument");
    return rc;
  } else if (rc != 3) {
    fprintf(stderr,
            "Error: Unable to parse argument '-%c %s' as a height "
            " x width x depth resolution.\n",
            option, arg_str);
    return -EINVAL;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_resolution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe96(%rip),%rsi
call   1040 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1193 <parse_resolution+0x63>
lea    0xe87(%rip),%rdi
call   1050 <perror@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11db <parse_resolution+0xab>
cmpl   $0x3,-0x2c(%rbp)
je     11cf <parse_resolution+0x9f>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    -0x5(%rbp),%al
mov    -0x10(%rbp),%rcx
lea    0xe6f(%rip),%rsi
movsbl %al,%edx
call   1030 <fprintf@plt>
xor    %eax,%eax
mov    0x2e0b(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11db <parse_resolution+0xab>
jmp    11d4 <parse_resolution+0xa4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_resolution>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
call   1040 <sscanf@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1187 <parse_resolution+0x57>
xor    %eax,%eax
cmp    $0x3,%ebx
je     1182 <parse_resolution+0x52>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
movsbl %bpl,%edx
lea    0xeb4(%rip),%rsi
mov    %r14,%rcx
call   1030 <fprintf@plt>
mov    0x2e52(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe7c(%rip),%rdi
call   1050 <perror@plt>
mov    %ebx,%eax
jmp    1182 <parse_resolution+0x52>

LLVM IR (-O0):
@optarg = global i32 0
@.str = [10 x i8] c"%dx%dx%d\0A\00"
@.str.1 = [25 x i8] c"Unable to parse argument\00"
@stderr = global i32 0
@.str.2 = [83 x i8] c"Error: Unable to parse argument '-%c %s' as a height x width x depth resolution.\0A\00"
@EINVAL = global i32 0
define i32 @parse_resolution(i8 signext %0, i8* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
store i8 %0, i8* %7
store i8* %1, i8** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
%13 = load i32, i32* @optarg
%14 = load i32*, i32** %9
%15 = load i32*, i32** %10
%16 = load i32*, i32** %11
%17 = call i32 @sscanf(i32 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %14, i32* %15, i32* %16)
store i32 %17, i32* %12
%18 = load i32, i32* %12
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %5
%21 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* %12
store i32 %22, i32* %6
br label %35
23: ; preds = %5
%24 = load i32, i32* %12
%25 = icmp ne i32 %24, 3
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = load i8, i8* %7
%29 = load i8*, i8** %8
%30 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.2, i64 0, i64 0), i8 signext %28, i8* %29)
%31 = load i32, i32* @EINVAL
%32 = sub nsw i32 0, %31
store i32 %32, i32* %6
br label %35
33: ; preds = %23
br label %34
34: ; preds = %33
store i32 0, i32* %6
br label %35
35: ; preds = %34, %26, %20
%36 = load i32, i32* %6
ret i32 %36
}

LLVM IR (-O2):
@optarg = global i32 0
@.str = [10 x i8] c"%dx%dx%d\0A\00"
@.str.1 = [25 x i8] c"Unable to parse argument\00"
@stderr = global i32 0
@.str.2 = [83 x i8] c"Error: Unable to parse argument '-%c %s' as a height x width x depth resolution.\0A\00"
@EINVAL = global i32 0
define i32 @parse_resolution(i8 signext %0, i8* %1, i32* %2, i32* %3, i32* %4) {
%6 = load i32, i32* @optarg
%7 = tail call i32 @sscanf(i32 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %18
11: ; preds = %5
%12 = icmp eq i32 %7, 3
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.2, i64 0, i64 0), i8 signext %0, i8* %1)
%16 = load i32, i32* @EINVAL
%17 = sub nsw i32 0, %16
br label %18
18: ; preds = %11, %13, %9
%19 = phi i32 [ %7, %9 ], [ %17, %13 ], [ 0, %11 ]
ret i32 %19
}