#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef scalar_t__ uint32_t;
struct TYPE_2__ {
  int data;
};
struct dtv_property {
  TYPE_1__ u;
  int /*<<< orphan*/ cmd;
};

/* Variables and functions */
int /*<<< orphan*/ DTV_FREQUENCY;
scalar_t__ atoi(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int set_isdb_s_frequency(const char *channel, struct dtv_property *prop) {
  uint32_t fe_freq;
  prop->cmd = DTV_FREQUENCY;
  if (((channel[0] == 'b') || (channel[0] == 'B')) &&
      ((channel[1] == 's') || (channel[1] == 'S'))) {
    if ((fe_freq = (uint32_t)atoi(channel + 2)) == 0) {
      fprintf(stderr, "Error: channel is not BSnn (nn=numeric)\n");
      return 1;
    }
    prop->u.data = fe_freq * 19180 + 1030300;
  } else if (((channel[0] == 'n') || (channel[0] == 'N')) &&
             ((channel[1] == 'd') || (channel[1] == 'D'))) {
    if ((fe_freq = (uint32_t)atoi(channel + 2)) == 0) {
      fprintf(stderr, "Error: channel is not NDnn (nn=numeric)\n");
      return 1;
    }
    prop->u.data = fe_freq * 20000 + 1573000;
  } else {
    fprintf(stderr, "Error: channel is invalid\n");
    return 1;
  }
  fprintf(stderr, "Info: Tuning to %d MHz\n", prop->u.data / 1000);
  return 0;
}


x86 assembly (clang, -O0):
<set_isdb_s_frequency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2ea1(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
je     1160 <set_isdb_s_frequency+0x40>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x42,%eax
jne    11db <set_isdb_s_frequency+0xbb>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x73,%eax
je     1182 <set_isdb_s_frequency+0x62>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x53,%eax
jne    11db <set_isdb_s_frequency+0xbb>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
call   1040 <atoi@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11c0 <set_isdb_s_frequency+0xa0>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12cc <set_isdb_s_frequency+0x1ac>
imul   $0x4aec,-0x20(%rbp),%rax
add    $0xfb89c,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    129e <set_isdb_s_frequency+0x17e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
je     11fb <set_isdb_s_frequency+0xdb>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4e,%eax
jne    1276 <set_isdb_s_frequency+0x156>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
je     121d <set_isdb_s_frequency+0xfd>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x44,%eax
jne    1276 <set_isdb_s_frequency+0x156>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
call   1040 <atoi@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    125b <set_isdb_s_frequency+0x13b>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12cc <set_isdb_s_frequency+0x1ac>
imul   $0x4e20,-0x20(%rbp),%rax
add    $0x180088,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1299 <set_isdb_s_frequency+0x179>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12cc <set_isdb_s_frequency+0x1ac>
jmp    129e <set_isdb_s_frequency+0x17e>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_isdb_s_frequency>:
push   %rbx
mov    %rsi,%rbx
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsi)
mov    (%rdi),%al
cmp    $0x61,%al
jg     113c <set_isdb_s_frequency+0x1c>
cmp    $0x42,%al
jne    1171 <set_isdb_s_frequency+0x51>
jmp    1148 <set_isdb_s_frequency+0x28>
cmp    $0x6e,%al
je     1175 <set_isdb_s_frequency+0x55>
cmp    $0x62,%al
jne    11ce <set_isdb_s_frequency+0xae>
mov    0x1(%rdi),%cl
or     $0x20,%cl
cmp    $0x73,%cl
jne    1171 <set_isdb_s_frequency+0x51>
add    $0x2,%rdi
call   1040 <atoi@plt>
test   %rax,%rax
je     11f2 <set_isdb_s_frequency+0xd2>
mov    $0xfb89c,%ecx
mov    $0x4aec,%edx
jmp    1196 <set_isdb_s_frequency+0x76>
cmp    $0x4e,%al
jne    11ce <set_isdb_s_frequency+0xae>
mov    0x1(%rdi),%al
or     $0x20,%al
cmp    $0x64,%al
jne    11ce <set_isdb_s_frequency+0xae>
add    $0x2,%rdi
call   1040 <atoi@plt>
test   %rax,%rax
je     11e0 <set_isdb_s_frequency+0xc0>
mov    $0x180088,%ecx
mov    $0x4e20,%edx
imul   %edx,%eax
add    %ecx,%eax
mov    %eax,(%rbx)
mov    0x2e3c(%rip),%rcx
mov    (%rcx),%edi
cltq
imul   $0x10624dd3,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x26,%rdx
add    %eax,%edx
lea    0xeaa(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    120e <set_isdb_s_frequency+0xee>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
jmp    1202 <set_isdb_s_frequency+0xe2>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
jmp    1202 <set_isdb_s_frequency+0xe2>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    0xdfe(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.dtv_property = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@DTV_FREQUENCY = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"Error: channel is not BSnn (nn=numeric)\0A\00"
@.str.1 = [41 x i8] c"Error: channel is not NDnn (nn=numeric)\0A\00"
@.str.2 = [27 x i8] c"Error: channel is invalid\0A\00"
@.str.3 = [24 x i8] c"Info: Tuning to %d MHz\0A\00"
define i32 @set_isdb_s_frequency(i8* %0, %struct.dtv_property* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.dtv_property*
%6 = alloca i64
store i8* %0, i8** %4
store %struct.dtv_property* %1, %struct.dtv_property** %5
%7 = load i32, i32* @DTV_FREQUENCY
%8 = load %struct.dtv_property*, %struct.dtv_property** %5
%9 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %8, i32 0, i32 1
store i32 %7, i32* %9
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 98
br i1 %14, label %21, label %15
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 66
br i1 %20, label %21, label %49
21: ; preds = %15, %2
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 115
br i1 %26, label %33, label %27
27: ; preds = %21
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 83
br i1 %32, label %33, label %49
33: ; preds = %27, %21
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = call i64 @atoi(i8* %35)
store i64 %36, i64* %6
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %101
41: ; preds = %33
%42 = load i64, i64* %6
%43 = mul nsw i64 %42, 19180
%44 = add nsw i64 %43, 1030300
%45 = trunc i64 %44 to i32
%46 = load %struct.dtv_property*, %struct.dtv_property** %5
%47 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %46, i32 0, i32 0
%48 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %47, i32 0, i32 0
store i32 %45, i32* %48
br label %93
49: ; preds = %27, %15
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 110
br i1 %54, label %61, label %55
55: ; preds = %49
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 78
br i1 %60, label %61, label %89
61: ; preds = %55, %49
%62 = load i8*, i8** %4
%63 = getelementptr inbounds i8, i8* %62, i64 1
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 100
br i1 %66, label %73, label %67
67: ; preds = %61
%68 = load i8*, i8** %4
%69 = getelementptr inbounds i8, i8* %68, i64 1
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 68
br i1 %72, label %73, label %89
73: ; preds = %67, %61
%74 = load i8*, i8** %4
%75 = getelementptr inbounds i8, i8* %74, i64 2
%76 = call i64 @atoi(i8* %75)
store i64 %76, i64* %6
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %73
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %101
81: ; preds = %73
%82 = load i64, i64* %6
%83 = mul nsw i64 %82, 20000
%84 = add nsw i64 %83, 1573000
%85 = trunc i64 %84 to i32
%86 = load %struct.dtv_property*, %struct.dtv_property** %5
%87 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %86, i32 0, i32 0
%88 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %87, i32 0, i32 0
store i32 %85, i32* %88
br label %92
89: ; preds = %67, %55
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %101
92: ; preds = %81
br label %93
93: ; preds = %92, %41
%94 = load i32, i32* @stderr
%95 = load %struct.dtv_property*, %struct.dtv_property** %5
%96 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %95, i32 0, i32 0
%97 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %96, i32 0, i32 0
%98 = load i32, i32* %97
%99 = sdiv i32 %98, 1000
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %99)
store i32 0, i32* %3
br label %101
101: ; preds = %93, %89, %78, %38
%102 = load i32, i32* %3
ret i32 %102
}

LLVM IR (-O2):
%struct.dtv_property = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@DTV_FREQUENCY = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"Error: channel is not BSnn (nn=numeric)\0A\00"
@.str.1 = [41 x i8] c"Error: channel is not NDnn (nn=numeric)\0A\00"
@.str.2 = [27 x i8] c"Error: channel is invalid\0A\00"
@.str.3 = [24 x i8] c"Info: Tuning to %d MHz\0A\00"
define i32 @set_isdb_s_frequency(i8* nocapture %0, %struct.dtv_property* nocapture %1) {
%3 = load i32, i32* @DTV_FREQUENCY
%4 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %1, i64 0, i32 1
store i32 %3, i32* %4
%5 = load i8, i8* %0
switch i8 %5, label %28 [
i8 98, label %6
i8 66, label %6
i8 110, label %18
i8 78, label %18
]
6: ; preds = %2, %2
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
switch i8 %8, label %16 [
i8 115, label %9
i8 83, label %9
]
9: ; preds = %6, %6
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = tail call i64 @atoi(i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %31
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %42
16: ; preds = %6
%17 = icmp eq i8 %5, 78
br i1 %17, label %18, label %28
18: ; preds = %16, %2, %2
%19 = getelementptr inbounds i8, i8* %0, i64 1
%20 = load i8, i8* %19
switch i8 %20, label %28 [
i8 100, label %21
i8 68, label %21
]
21: ; preds = %18, %18
%22 = getelementptr inbounds i8, i8* %0, i64 2
%23 = tail call i64 @atoi(i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %42
28: ; preds = %16, %2, %18
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %42
31: ; preds = %21, %9
%32 = phi i64 [ %11, %9 ], [ %23, %21 ]
%33 = phi i32 [ 19180, %9 ], [ 20000, %21 ]
%34 = phi i32 [ 1030300, %9 ], [ 1573000, %21 ]
%35 = trunc i64 %32 to i32
%36 = mul i32 %33, %35
%37 = add i32 %36, %34
%38 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %1, i64 0, i32 0, i32 0
store i32 %37, i32* %38
%39 = load i32, i32* @stderr
%40 = sdiv i32 %37, 1000
%41 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %31, %28, %25, %13
%43 = phi i32 [ 1, %13 ], [ 0, %31 ], [ 1, %25 ], [ 1, %28 ]
ret i32 %43
}