#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_t_frequency(const char *channel, struct dtv_property *prop) {
  uint32_t fe_freq;
  prop->cmd = DTV_FREQUENCY;
  if ((fe_freq = (uint32_t)atoi(channel)) == 0) {
    fprintf(stderr, "Error: channel is not number\n");
    return 1;
  }
  prop->u.data = (fe_freq * 6000 + 395143) * 1000;
  fprintf(stderr, "Info: Tuning to %d kHz\n", prop->u.data / 1000);
  return 0;
}


x86 assembly (clang, -O0):
<set_isdb_t_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),%rdi
call   1040 <atoi@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    117a <set_isdb_t_frequency+0x5a>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c5 <set_isdb_t_frequency+0xa5>
imul   $0x1770,-0x20(%rbp),%rax
add    $0x60787,%rax
imul   $0x3e8,%rax,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe67(%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_t_frequency>:
push   %rbx
mov    %rsi,%rbx
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsi)
call   1040 <atoi@plt>
test   %rax,%rax
je     1178 <set_isdb_t_frequency+0x58>
imul   $0x5b8d80,%eax,%eax
add    $0x178d6758,%eax
mov    %eax,(%rbx)
mov    0x2e92(%rip),%rcx
mov    (%rcx),%edi
cltq
imul   $0x10624dd3,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x26,%rdx
add    %eax,%edx
lea    0xeb1(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1194 <set_isdb_t_frequency+0x74>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%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 = [30 x i8] c"Error: channel is not number\0A\00"
@.str.1 = [24 x i8] c"Info: Tuning to %d kHz\0A\00"
define i32 @set_isdb_t_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 = call i64 @atoi(i8* %10)
store i64 %11, i64* %6
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %32
16: ; preds = %2
%17 = load i64, i64* %6
%18 = mul nsw i64 %17, 6000
%19 = add nsw i64 %18, 395143
%20 = mul nsw i64 %19, 1000
%21 = trunc i64 %20 to i32
%22 = load %struct.dtv_property*, %struct.dtv_property** %5
%23 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %22, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
store i32 %21, i32* %24
%25 = load i32, i32* @stderr
%26 = load %struct.dtv_property*, %struct.dtv_property** %5
%27 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %26, i32 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %27, i32 0, i32 0
%29 = load i32, i32* %28
%30 = sdiv i32 %29, 1000
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %30)
store i32 0, i32* %3
br label %32
32: ; preds = %16, %13
%33 = load i32, i32* %3
ret i32 %33
}

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 = [30 x i8] c"Error: channel is not number\0A\00"
@.str.1 = [24 x i8] c"Info: Tuning to %d kHz\0A\00"
define i32 @set_isdb_t_frequency(i8* nocapture %0, %struct.dtv_property* nocapture writeonly %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 = tail call i64 @atoi(i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %18
10: ; preds = %2
%11 = trunc i64 %5 to i32
%12 = mul i32 %11, 6000000
%13 = add i32 %12, 395143000
%14 = getelementptr inbounds %struct.dtv_property, %struct.dtv_property* %1, i64 0, i32 0, i32 0
store i32 %13, i32* %14
%15 = load i32, i32* @stderr
%16 = sdiv i32 %13, 1000
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %10, %7
%19 = phi i32 [ 1, %7 ], [ 0, %10 ]
ret i32 %19
}