#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
int /*<<< orphan*/ isdigit(unsigned char);
int sscanf(char *, char *, scalar_t__ *, scalar_t__ *);
scalar_t__ strrchr(char const *, char);
int select_input_res_auto(const char *file_name, int32_t *out_width,
                          int32_t *out_height) {
  if (!file_name)
    return 0;
  unsigned char *sub_str =
      (unsigned char *)(((strrchr(file_name, '/')) > (strrchr(file_name, '\\')))
                            ? (strrchr(file_name, '/'))
                            : (strrchr(file_name, '\\')));
  if (!sub_str)
    sub_str = (unsigned char *)file_name;
  int success = 0;
  do {
    success = (sscanf((char *)sub_str, "%dx%d%*s", out_width, out_height) == 2);
    success &= (*out_width > 0 && *out_height > 0);
    do {
      ++sub_str;
    } while (*sub_str != 0 && !isdigit(*sub_str));
  } while (*sub_str != 0 && !success);
  return success;
}


x86 assembly (clang, -O0):
<select_input_res_auto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115b <select_input_res_auto+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    12a5 <select_input_res_auto+0x175>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jle    11a2 <select_input_res_auto+0x72>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x40(%rbp)
jmp    11b4 <select_input_res_auto+0x84>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11cf <select_input_res_auto+0x9f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe17(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x41(%rbp)
jle    121d <select_input_res_auto+0xed>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
setg   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
and    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x42(%rbp)
je     1263 <select_input_res_auto+0x133>
mov    -0x28(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
test   $0x1,%al
jne    122b <select_input_res_auto+0xfb>
jmp    1273 <select_input_res_auto+0x143>
mov    -0x28(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x43(%rbp)
je     1294 <select_input_res_auto+0x164>
cmpl   $0x0,-0x2c(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x43(%rbp)
mov    -0x43(%rbp),%al
test   $0x1,%al
jne    11d6 <select_input_res_auto+0xa6>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_input_res_auto>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11f9 <select_input_res_auto+0xc9>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x2f,%r13d
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
mov    $0x5c,%ebp
mov    %r12,%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
cmp    %rax,%rbx
cmovg  %r13d,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
test   %rax,%rax
cmove  %r12,%rbx
lea    0xe6c(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <sscanf@plt>
cmpq   $0x0,(%r15)
jle    11c0 <select_input_res_auto+0x90>
cmpq   $0x0,(%r14)
setg   %cl
jmp    11c2 <select_input_res_auto+0x92>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ecx,%ecx
cmp    $0x2,%eax
sete   %bpl
and    %cl,%bpl
nopl   0x0(%rax)
movzbl 0x1(%rbx),%eax
test   %al,%al
je     11f3 <select_input_res_auto+0xc3>
add    $0x1,%rbx
movzbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11d0 <select_input_res_auto+0xa0>
cmpb   $0x0,(%rbx)
je     11f3 <select_input_res_auto+0xc3>
mov    %ebp,%eax
xor    $0x1,%al
jne    1194 <select_input_res_auto+0x64>
movzbl %bpl,%eax
jmp    11fb <select_input_res_auto+0xcb>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%dx%d%*s\00"
define i32 @select_input_res_auto(i8* %0, i64* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i64* %1, i64** %6
store i64* %2, i64** %7
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %3
store i32 0, i32* %4
br label %82
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = call i64 @strrchr(i8* %14, i8 signext 47)
%16 = load i8*, i8** %5
%17 = call i64 @strrchr(i8* %16, i8 signext 92)
%18 = icmp sgt i64 %15, %17
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i8*, i8** %5
%21 = call i64 @strrchr(i8* %20, i8 signext 47)
br label %25
22: ; preds = %13
%23 = load i8*, i8** %5
%24 = call i64 @strrchr(i8* %23, i8 signext 92)
br label %25
25: ; preds = %22, %19
%26 = phi i64 [ %21, %19 ], [ %24, %22 ]
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = icmp ne i8* %28, null
br i1 %29, label %32, label %30
30: ; preds = %25
%31 = load i8*, i8** %5
store i8* %31, i8** %8
br label %32
32: ; preds = %30, %25
store i32 0, i32* %9
br label %33
33: ; preds = %78, %32
%34 = load i8*, i8** %8
%35 = load i64*, i64** %6
%36 = load i64*, i64** %7
%37 = call i32 @sscanf(i8* %34, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64* %35, i64* %36)
%38 = icmp eq i32 %37, 2
%39 = zext i1 %38 to i32
store i32 %39, i32* %9
%40 = load i64*, i64** %6
%41 = load i64, i64* %40
%42 = icmp sgt i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %33
%44 = load i64*, i64** %7
%45 = load i64, i64* %44
%46 = icmp sgt i64 %45, 0
br label %47
47: ; preds = %43, %33
%48 = phi i1 [ false, %33 ], [ %46, %43 ]
%49 = zext i1 %48 to i32
%50 = load i32, i32* %9
%51 = and i32 %50, %49
store i32 %51, i32* %9
br label %52
52: ; preds = %66, %47
%53 = load i8*, i8** %8
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %8
br label %55
55: ; preds = %52
%56 = load i8*, i8** %8
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %55
%61 = load i8*, i8** %8
%62 = load i8, i8* %61
%63 = call i32 @isdigit(i8 zeroext %62)
%64 = icmp ne i32 %63, 0
%65 = xor i1 %64, true
br label %66
66: ; preds = %60, %55
%67 = phi i1 [ false, %55 ], [ %65, %60 ]
br i1 %67, label %52, label %68
68: ; preds = %66
br label %69
69: ; preds = %68
%70 = load i8*, i8** %8
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %69
%75 = load i32, i32* %9
%76 = icmp ne i32 %75, 0
%77 = xor i1 %76, true
br label %78
78: ; preds = %74, %69
%79 = phi i1 [ false, %69 ], [ %77, %74 ]
br i1 %79, label %33, label %80
80: ; preds = %78
%81 = load i32, i32* %9
store i32 %81, i32* %4
br label %82
82: ; preds = %80, %12
%83 = load i32, i32* %4
ret i32 %83
}

LLVM IR (-O2):
@.str = [9 x i8] c"%dx%d%*s\00"
define i32 @select_input_res_auto(i8* %0, i64* %1, i64* %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %41, label %5
5: ; preds = %3
%6 = tail call i64 @strrchr(i8* %0, i8 signext 47)
%7 = tail call i64 @strrchr(i8* %0, i8 signext 92)
%8 = icmp sgt i64 %6, %7
%9 = select i1 %8, i8 47, i8 92
%10 = tail call i64 @strrchr(i8* %0, i8 signext %9)
%11 = inttoptr i64 %10 to i8*
%12 = icmp eq i64 %10, 0
%13 = select i1 %12, i8* %0, i8* %11
br label %14
14: ; preds = %34, %5
%15 = phi i8* [ %13, %5 ], [ %28, %34 ]
%16 = tail call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2)
%17 = icmp eq i32 %16, 2
%18 = load i64, i64* %1
%19 = icmp sgt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i64, i64* %2
%22 = icmp sgt i64 %21, 0
br label %23
23: ; preds = %20, %14
%24 = phi i1 [ false, %14 ], [ %22, %20 ]
%25 = and i1 %17, %24
br label %26
26: ; preds = %31, %23
%27 = phi i8* [ %15, %23 ], [ %28, %31 ]
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %39, label %31
31: ; preds = %26
%32 = tail call i32 @isdigit(i8 zeroext %29)
%33 = icmp eq i32 %32, 0
br i1 %33, label %26, label %34
34: ; preds = %31
%35 = load i8, i8* %28
%36 = icmp ne i8 %35, 0
%37 = xor i1 %25, true
%38 = select i1 %36, i1 %37, i1 false
br i1 %38, label %14, label %39
39: ; preds = %34, %26
%40 = zext i1 %25 to i32
br label %41
41: ; preds = %39, %3
%42 = phi i32 [ 0, %3 ], [ %40, %39 ]
ret i32 %42
}