#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*/ strcasecmp(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ videoinput_get_norm_name(int);
int videoinput_get_norm_number(const char *name) {
  int i;
  for (i = 0; i < 7 + 1; i++) {
    if (!strcasecmp(name, videoinput_get_norm_name(i))) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<videoinput_get_norm_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    117f <videoinput_get_norm_number+0x5f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <videoinput_get_norm_name@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    116c <videoinput_get_norm_number+0x4c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <videoinput_get_norm_number+0x66>
jmp    1171 <videoinput_get_norm_number+0x51>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <videoinput_get_norm_number+0x13>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<videoinput_get_norm_number>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %edi,%edi
call   1040 <videoinput_get_norm_name@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1212 <videoinput_get_norm_number+0xf2>
mov    $0x1,%ebp
mov    $0x1,%edi
call   1040 <videoinput_get_norm_name@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1212 <videoinput_get_norm_number+0xf2>
mov    $0x2,%ebp
mov    $0x2,%edi
call   1040 <videoinput_get_norm_name@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1212 <videoinput_get_norm_number+0xf2>
mov    $0x3,%ebp
mov    $0x3,%edi
call   1040 <videoinput_get_norm_name@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1212 <videoinput_get_norm_number+0xf2>
mov    $0x4,%ebp
mov    $0x4,%edi
call   1040 <videoinput_get_norm_name@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1212 <videoinput_get_norm_number+0xf2>
mov    $0x5,%ebp
mov    $0x5,%edi
call   1040 <videoinput_get_norm_name@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1212 <videoinput_get_norm_number+0xf2>
mov    $0x6,%ebp
mov    $0x6,%edi
call   1040 <videoinput_get_norm_name@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1212 <videoinput_get_norm_number+0xf2>
mov    $0x7,%edi
call   1040 <videoinput_get_norm_name@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcasecmp@plt>
neg    %eax
sbb    %ebp,%ebp
or     $0x7,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @videoinput_get_norm_number(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = call i32 @videoinput_get_norm_name(i32 %10)
%12 = call i32 @strcasecmp(i8* %9, i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %8
%15 = load i32, i32* %4
store i32 %15, i32* %2
br label %21
16: ; preds = %8
br label %17
17: ; preds = %16
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %5
20: ; preds = %5
store i32 -1, i32* %2
br label %21
21: ; preds = %20, %14
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
define i32 @videoinput_get_norm_number(i8* %0) {
%2 = tail call i32 @videoinput_get_norm_name(i32 0)
%3 = tail call i32 @strcasecmp(i8* %0, i32 %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %34, label %5
5: ; preds = %1
%6 = tail call i32 @videoinput_get_norm_name(i32 1)
%7 = tail call i32 @strcasecmp(i8* %0, i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %34, label %9
9: ; preds = %5
%10 = tail call i32 @videoinput_get_norm_name(i32 2)
%11 = tail call i32 @strcasecmp(i8* %0, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %34, label %13
13: ; preds = %9
%14 = tail call i32 @videoinput_get_norm_name(i32 3)
%15 = tail call i32 @strcasecmp(i8* %0, i32 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %34, label %17
17: ; preds = %13
%18 = tail call i32 @videoinput_get_norm_name(i32 4)
%19 = tail call i32 @strcasecmp(i8* %0, i32 %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %34, label %21
21: ; preds = %17
%22 = tail call i32 @videoinput_get_norm_name(i32 5)
%23 = tail call i32 @strcasecmp(i8* %0, i32 %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %34, label %25
25: ; preds = %21
%26 = tail call i32 @videoinput_get_norm_name(i32 6)
%27 = tail call i32 @strcasecmp(i8* %0, i32 %26)
%28 = icmp eq i32 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %25
%30 = tail call i32 @videoinput_get_norm_name(i32 7)
%31 = tail call i32 @strcasecmp(i8* %0, i32 %30)
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, i32 7, i32 -1
br label %34
34: ; preds = %29, %25, %21, %17, %13, %9, %5, %1
%35 = phi i32 [ 0, %1 ], [ 1, %5 ], [ 2, %9 ], [ 3, %13 ], [ 4, %17 ], [ 5, %21 ], [ 6, %25 ], [ %33, %29 ]
ret i32 %35
}