#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 */
scalar_t__ ERANGE;
int /*<<< orphan*/ EXIT_FAILURE;
int LONG_MAX;
int LONG_MIN;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char const *);
int strtol(char const *, char const *, int);
int main(int argc, char const *argv[]) {
  int R, N, O, target_frequency, channel_spacing, receive_offset;
  if (argc < 2 || argc > 3) {
    printf("usage:\n\trncalc target_frequency_kHz [receive_offset_kHz] "
           "[channel_spacing_kHz]\n");
    return -0;
  }
  target_frequency = strtol(argv[1], argv[1] + strlen(argv[1]), 10) * 1000;
  if ((errno == ERANGE &&
       (target_frequency == LONG_MAX || target_frequency == LONG_MIN)) ||
      (errno != 0 && target_frequency == 0)) {
    perror("Faulty target_frequency");
    exit(EXIT_FAILURE);
  }
  if (argc == 3) {
    receive_offset = strtol(argv[2], argv[2] + strlen(argv[2]), 10) * 1000;
    if ((errno == ERANGE &&
         (receive_offset == LONG_MAX || receive_offset == LONG_MIN)) ||
        (errno != 0 && receive_offset == 0)) {
      perror("Faulty receive_offset");
      exit(EXIT_FAILURE);
    }
  } else
    receive_offset = 21400000;
  if (argc == 4) {
    channel_spacing = strtol(argv[3], argv[3] + strlen(argv[3]), 10) * 1000;
    if ((errno == ERANGE &&
         (channel_spacing == LONG_MAX || channel_spacing == LONG_MIN)) ||
        (errno != 0 && channel_spacing == 0)) {
      perror("Faulty channel_spacing");
      exit(EXIT_FAILURE);
    }
  } else
    channel_spacing = 25000;
  R = 10000000 / channel_spacing;
  if (10000000 % channel_spacing != 0) {
    channel_spacing = 10000000 / R;
    printf("Channel spacing is rounded to %d\n", channel_spacing);
  } else {
    printf("Channel spacing is set to %d\n", channel_spacing);
  }
  N = target_frequency / channel_spacing;
  if (target_frequency % channel_spacing != 0) {
    target_frequency = N * channel_spacing;
    printf("Target frequency is rounded to %d\n", target_frequency);
  } else {
    printf("Target frequency is set to %d\n", target_frequency);
  }
  O = receive_offset / channel_spacing;
  if (receive_offset % channel_spacing != 0) {
    receive_offset = O * channel_spacing;
    printf("Receive offset is rounded to %d\n", receive_offset);
  } else {
    printf("Receive offset is set to %d\n", receive_offset);
  }
  printf("N=%d\n", N);
  printf("R=%d\n", R);
  printf("O=%d\n", O);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     117a <main+0x2a>
cmpl   $0x3,-0x8(%rbp)
jle    1194 <main+0x44>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1509 <main+0x3b9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
imul   $0x3e8,%eax,%eax
mov    %eax,-0x20(%rbp)
mov    0x2de8(%rip),%rax
mov    (%rax),%rax
mov    0x2df6(%rip),%rcx
cmp    (%rcx),%rax
jne    1217 <main+0xc7>
mov    -0x20(%rbp),%eax
mov    0x2dd3(%rip),%rcx
cmp    (%rcx),%eax
je     1232 <main+0xe2>
mov    -0x20(%rbp),%eax
mov    0x2dd9(%rip),%rcx
cmp    (%rcx),%eax
je     1232 <main+0xe2>
mov    0x2daa(%rip),%rax
cmpq   $0x0,(%rax)
je     124c <main+0xfc>
cmpl   $0x0,-0x20(%rbp)
jne    124c <main+0xfc>
lea    0xe17(%rip),%rdi
call   1060 <perror@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    1313 <main+0x1c3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdi
cltq
add    %rax,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
imul   $0x3e8,%eax,%eax
mov    %eax,-0x28(%rbp)
mov    0x2d26(%rip),%rax
mov    (%rax),%rax
mov    0x2d34(%rip),%rcx
cmp    (%rcx),%rax
jne    12d9 <main+0x189>
mov    -0x28(%rbp),%eax
mov    0x2d11(%rip),%rcx
cmp    (%rcx),%eax
je     12f4 <main+0x1a4>
mov    -0x28(%rbp),%eax
mov    0x2d17(%rip),%rcx
cmp    (%rcx),%eax
je     12f4 <main+0x1a4>
mov    0x2ce8(%rip),%rax
cmpq   $0x0,(%rax)
je     130e <main+0x1be>
cmpl   $0x0,-0x28(%rbp)
jne    130e <main+0x1be>
lea    0xd6d(%rip),%rdi
call   1060 <perror@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    131a <main+0x1ca>
movl   $0x14689c0,-0x28(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    13e1 <main+0x291>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdi
cltq
add    %rax,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
imul   $0x3e8,%eax,%eax
mov    %eax,-0x24(%rbp)
mov    0x2c58(%rip),%rax
mov    (%rax),%rax
mov    0x2c66(%rip),%rcx
cmp    (%rcx),%rax
jne    13a7 <main+0x257>
mov    -0x24(%rbp),%eax
mov    0x2c43(%rip),%rcx
cmp    (%rcx),%eax
je     13c2 <main+0x272>
mov    -0x24(%rbp),%eax
mov    0x2c49(%rip),%rcx
cmp    (%rcx),%eax
je     13c2 <main+0x272>
mov    0x2c1a(%rip),%rax
cmpq   $0x0,(%rax)
je     13dc <main+0x28c>
cmpl   $0x0,-0x24(%rbp)
jne    13dc <main+0x28c>
lea    0xcb5(%rip),%rdi
call   1060 <perror@plt>
mov    0x2beb(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    13e8 <main+0x298>
movl   $0x61a8,-0x24(%rbp)
mov    $0x989680,%eax
cltd
idivl  -0x24(%rbp)
mov    %eax,-0x14(%rbp)
mov    $0x989680,%eax
cltd
idivl  -0x24(%rbp)
cmp    $0x0,%edx
je     1428 <main+0x2d8>
mov    $0x989680,%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xc79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1439 <main+0x2e9>
mov    -0x24(%rbp),%esi
lea    0xc85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
cltd
idivl  -0x24(%rbp)
cmp    $0x0,%edx
je     1473 <main+0x323>
mov    -0x18(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xc6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1484 <main+0x334>
mov    -0x20(%rbp),%esi
lea    0xc7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%eax
cltd
idivl  -0x24(%rbp)
cmp    $0x0,%edx
je     14be <main+0x36e>
mov    -0x1c(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xc65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14cf <main+0x37f>
mov    -0x28(%rbp),%esi
lea    0xc70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xc7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xc71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xc66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    -0x4(%rbx),%eax
cmp    $0xfffffffd,%eax
ja     1186 <main+0x26>
lea    0xf62(%rip),%rdi
call   1030 <puts@plt>
jmp    1341 <main+0x1e1>
mov    %rsi,%r13
mov    0x8(%rsi),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
movslq %eax,%rsi
add    %rbp,%rsi
mov    %rbp,%rdi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%r12d
imul   $0x3e8,%eax,%r14d
mov    0x2e0f(%rip),%rdx
mov    (%rdx),%rax
mov    0x2e1d(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    11e9 <main+0x89>
mov    0x2e00(%rip),%rcx
cmp    (%rcx),%r14d
je     1352 <main+0x1f2>
mov    0x2e08(%rip),%rcx
cmp    (%rcx),%r14d
je     1352 <main+0x1f2>
test   %rax,%rax
je     11f7 <main+0x97>
test   %r12d,%r12d
je     1352 <main+0x1f2>
mov    $0x14689c0,%r15d
cmp    $0x3,%ebx
jne    1262 <main+0x102>
mov    0x10(%r13),%rbx
mov    %rbx,%rdi
mov    %rdx,%r13
call   1040 <strlen@plt>
movslq %eax,%rsi
add    %rbx,%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1060 <strtol@plt>
imul   $0x3e8,%eax,%r15d
mov    0x0(%r13),%rcx
cmp    0x0(%rbp),%rcx
jne    1255 <main+0xf5>
mov    0x2d94(%rip),%rdx
cmp    (%rdx),%r15d
je     135b <main+0x1fb>
mov    0x2d9c(%rip),%rdx
cmp    (%rdx),%r15d
je     135b <main+0x1fb>
test   %rcx,%rcx
je     1262 <main+0x102>
test   %eax,%eax
je     135b <main+0x1fb>
lea    0xdc5(%rip),%rdi
mov    $0x61a8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq %r12d,%rax
imul   $0x51eb851f,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x23,%rbx
add    %eax,%ebx
imul   $0xbcbe61d,%r14d,%eax
add    $0xa7c58,%eax
ror    $0x3,%eax
cmp    $0x29f17,%eax
jb     12b1 <main+0x151>
imul   $0x61a8,%ebx,%esi
lea    0xd9d(%rip),%rdi
jmp    12bb <main+0x15b>
lea    0xdb7(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq %r15d,%rax
imul   $0x14f8b589,%rax,%rbp
mov    %rbp,%rcx
shr    $0x3f,%rcx
sar    $0x2b,%rbp
add    %ecx,%ebp
imul   $0xbcbe61d,%eax,%eax
add    $0xa7c58,%eax
ror    $0x3,%eax
cmp    $0x29f17,%eax
jb     12fd <main+0x19d>
imul   $0x61a8,%ebp,%esi
lea    0xd93(%rip),%rdi
jmp    1307 <main+0x1a7>
lea    0xdab(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdb7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdad(%rip),%rdi
mov    $0x190,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xda0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xca7(%rip),%rdi
jmp    1362 <main+0x202>
lea    0xcb6(%rip),%rdi
call   1070 <perror@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [80 x i8] c"usage:\0A\09rncalc target_frequency_kHz [receive_offset_kHz] [channel_spacing_kHz]\0A\00"
@errno = global i64 0
@ERANGE = global i64 0
@LONG_MAX = global i32 0
@LONG_MIN = global i32 0
@.str.1 = [24 x i8] c"Faulty target_frequency\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [22 x i8] c"Faulty receive_offset\00"
@.str.3 = [23 x i8] c"Faulty channel_spacing\00"
@.str.4 = [34 x i8] c"Channel spacing is rounded to %d\0A\00"
@.str.5 = [30 x i8] c"Channel spacing is set to %d\0A\00"
@.str.6 = [35 x i8] c"Target frequency is rounded to %d\0A\00"
@.str.7 = [31 x i8] c"Target frequency is set to %d\0A\00"
@.str.8 = [33 x i8] c"Receive offset is rounded to %d\0A\00"
@.str.9 = [29 x i8] c"Receive offset is set to %d\0A\00"
@.str.10 = [6 x i8] c"N=%d\0A\00"
@.str.11 = [6 x i8] c"R=%d\0A\00"
@.str.12 = [6 x i8] c"O=%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 3
br i1 %16, label %17, label %19
17: ; preds = %14, %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %192
19: ; preds = %14
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strlen(i8* %28)
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %25, i64 %30
%32 = call i32 @strtol(i8* %22, i8* %31, i32 10)
%33 = mul nsw i32 %32, 1000
store i32 %33, i32* %9
%34 = load i64, i64* @errno
%35 = load i64, i64* @ERANGE
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %45
37: ; preds = %19
%38 = load i32, i32* %9
%39 = load i32, i32* @LONG_MAX
%40 = icmp eq i32 %38, %39
br i1 %40, label %51, label %41
41: ; preds = %37
%42 = load i32, i32* %9
%43 = load i32, i32* @LONG_MIN
%44 = icmp eq i32 %42, %43
br i1 %44, label %51, label %45
45: ; preds = %41, %19
%46 = load i64, i64* @errno
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i32, i32* %9
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %48, %41, %37
%52 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %48, %45
%56 = load i32, i32* %4
%57 = icmp eq i32 %56, 3
br i1 %57, label %58, label %95
58: ; preds = %55
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 2
%61 = load i8*, i8** %60
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 2
%64 = load i8*, i8** %63
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 2
%67 = load i8*, i8** %66
%68 = call i32 @strlen(i8* %67)
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %64, i64 %69
%71 = call i32 @strtol(i8* %61, i8* %70, i32 10)
%72 = mul nsw i32 %71, 1000
store i32 %72, i32* %11
%73 = load i64, i64* @errno
%74 = load i64, i64* @ERANGE
%75 = icmp eq i64 %73, %74
br i1 %75, label %76, label %84
76: ; preds = %58
%77 = load i32, i32* %11
%78 = load i32, i32* @LONG_MAX
%79 = icmp eq i32 %77, %78
br i1 %79, label %90, label %80
80: ; preds = %76
%81 = load i32, i32* %11
%82 = load i32, i32* @LONG_MIN
%83 = icmp eq i32 %81, %82
br i1 %83, label %90, label %84
84: ; preds = %80, %58
%85 = load i64, i64* @errno
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %94
87: ; preds = %84
%88 = load i32, i32* %11
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %87, %80, %76
%91 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 @exit(i32 %92)
unreachable
94: ; preds = %87, %84
br label %96
95: ; preds = %55
store i32 21400000, i32* %11
br label %96
96: ; preds = %95, %94
%97 = load i32, i32* %4
%98 = icmp eq i32 %97, 4
br i1 %98, label %99, label %136
99: ; preds = %96
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 3
%102 = load i8*, i8** %101
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 3
%105 = load i8*, i8** %104
%106 = load i8**, i8*** %5
%107 = getelementptr inbounds i8*, i8** %106, i64 3
%108 = load i8*, i8** %107
%109 = call i32 @strlen(i8* %108)
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %105, i64 %110
%112 = call i32 @strtol(i8* %102, i8* %111, i32 10)
%113 = mul nsw i32 %112, 1000
store i32 %113, i32* %10
%114 = load i64, i64* @errno
%115 = load i64, i64* @ERANGE
%116 = icmp eq i64 %114, %115
br i1 %116, label %117, label %125
117: ; preds = %99
%118 = load i32, i32* %10
%119 = load i32, i32* @LONG_MAX
%120 = icmp eq i32 %118, %119
br i1 %120, label %131, label %121
121: ; preds = %117
%122 = load i32, i32* %10
%123 = load i32, i32* @LONG_MIN
%124 = icmp eq i32 %122, %123
br i1 %124, label %131, label %125
125: ; preds = %121, %99
%126 = load i64, i64* @errno
%127 = icmp ne i64 %126, 0
br i1 %127, label %128, label %135
128: ; preds = %125
%129 = load i32, i32* %10
%130 = icmp eq i32 %129, 0
br i1 %130, label %131, label %135
131: ; preds = %128, %121, %117
%132 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%133 = load i32, i32* @EXIT_FAILURE
%134 = call i32 @exit(i32 %133)
unreachable
135: ; preds = %128, %125
br label %137
136: ; preds = %96
store i32 25000, i32* %10
br label %137
137: ; preds = %136, %135
%138 = load i32, i32* %10
%139 = sdiv i32 10000000, %138
store i32 %139, i32* %6
%140 = load i32, i32* %10
%141 = srem i32 10000000, %140
%142 = icmp ne i32 %141, 0
br i1 %142, label %143, label %148
143: ; preds = %137
%144 = load i32, i32* %6
%145 = sdiv i32 10000000, %144
store i32 %145, i32* %10
%146 = load i32, i32* %10
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %146)
br label %151
148: ; preds = %137
%149 = load i32, i32* %10
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %149)
br label %151
151: ; preds = %148, %143
%152 = load i32, i32* %9
%153 = load i32, i32* %10
%154 = sdiv i32 %152, %153
store i32 %154, i32* %7
%155 = load i32, i32* %9
%156 = load i32, i32* %10
%157 = srem i32 %155, %156
%158 = icmp ne i32 %157, 0
br i1 %158, label %159, label %165
159: ; preds = %151
%160 = load i32, i32* %7
%161 = load i32, i32* %10
%162 = mul nsw i32 %160, %161
store i32 %162, i32* %9
%163 = load i32, i32* %9
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %163)
br label %168
165: ; preds = %151
%166 = load i32, i32* %9
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %166)
br label %168
168: ; preds = %165, %159
%169 = load i32, i32* %11
%170 = load i32, i32* %10
%171 = sdiv i32 %169, %170
store i32 %171, i32* %8
%172 = load i32, i32* %11
%173 = load i32, i32* %10
%174 = srem i32 %172, %173
%175 = icmp ne i32 %174, 0
br i1 %175, label %176, label %182
176: ; preds = %168
%177 = load i32, i32* %8
%178 = load i32, i32* %10
%179 = mul nsw i32 %177, %178
store i32 %179, i32* %11
%180 = load i32, i32* %11
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %180)
br label %185
182: ; preds = %168
%183 = load i32, i32* %11
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %183)
br label %185
185: ; preds = %182, %176
%186 = load i32, i32* %7
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 %186)
%188 = load i32, i32* %6
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %188)
%190 = load i32, i32* %8
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %190)
store i32 0, i32* %3
br label %192
192: ; preds = %185, %17
%193 = load i32, i32* %3
ret i32 %193
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@LONG_MAX = global i32 0
@LONG_MIN = global i32 0
@.str.1 = [24 x i8] c"Faulty target_frequency\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [22 x i8] c"Faulty receive_offset\00"
@.str.5 = [30 x i8] c"Channel spacing is set to %d\0A\00"
@.str.6 = [35 x i8] c"Target frequency is rounded to %d\0A\00"
@.str.7 = [31 x i8] c"Target frequency is set to %d\0A\00"
@.str.8 = [33 x i8] c"Receive offset is rounded to %d\0A\00"
@.str.9 = [29 x i8] c"Receive offset is set to %d\0A\00"
@.str.10 = [6 x i8] c"N=%d\0A\00"
@.str.11 = [6 x i8] c"R=%d\0A\00"
@.str.12 = [6 x i8] c"O=%d\0A\00"
@str = [79 x i8] c"usage:\0A\09rncalc target_frequency_kHz [receive_offset_kHz] [channel_spacing_kHz]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -4
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str, i64 0, i64 0))
br label %83
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %9)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = tail call i32 @strtol(i8* %9, i8* %12, i32 10)
%14 = mul nsw i32 %13, 1000
%15 = load i64, i64* @errno
%16 = load i64, i64* @ERANGE
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %24
18: ; preds = %7
%19 = load i32, i32* @LONG_MAX
%20 = icmp eq i32 %14, %19
%21 = load i32, i32* @LONG_MIN
%22 = icmp eq i32 %14, %21
%23 = select i1 %20, i1 true, i1 %22
br i1 %23, label %28, label %24
24: ; preds = %18, %7
%25 = icmp ne i64 %15, 0
%26 = icmp eq i32 %13, 0
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %28, label %32
28: ; preds = %24, %18
%29 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %24
%33 = icmp eq i32 %0, 3
br i1 %33, label %34, label %59
34: ; preds = %32
%35 = getelementptr inbounds i8*, i8** %1, i64 2
%36 = load i8*, i8** %35
%37 = tail call i32 @strlen(i8* %36)
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = tail call i32 @strtol(i8* %36, i8* %39, i32 10)
%41 = mul nsw i32 %40, 1000
%42 = load i64, i64* @errno
%43 = load i64, i64* @ERANGE
%44 = icmp eq i64 %42, %43
br i1 %44, label %45, label %51
45: ; preds = %34
%46 = load i32, i32* @LONG_MAX
%47 = icmp eq i32 %41, %46
%48 = load i32, i32* @LONG_MIN
%49 = icmp eq i32 %41, %48
%50 = select i1 %47, i1 true, i1 %49
br i1 %50, label %55, label %51
51: ; preds = %45, %34
%52 = icmp ne i64 %42, 0
%53 = icmp eq i32 %40, 0
%54 = select i1 %52, i1 %53, i1 false
br i1 %54, label %55, label %59
55: ; preds = %51, %45
%56 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
%58 = tail call i32 @exit(i32 %57)
unreachable
59: ; preds = %51, %32
%60 = phi i32 [ %41, %51 ], [ 21400000, %32 ]
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 25000)
%62 = sdiv i32 %13, 25
%63 = srem i32 %14, 25000
%64 = icmp eq i32 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %59
%66 = mul nsw i32 %62, 25000
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %66)
br label %70
68: ; preds = %59
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %14)
br label %70
70: ; preds = %68, %65
%71 = sdiv i32 %60, 25000
%72 = srem i32 %60, 25000
%73 = icmp eq i32 %72, 0
br i1 %73, label %77, label %74
74: ; preds = %70
%75 = mul nsw i32 %71, 25000
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %75)
br label %79
77: ; preds = %70
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %60)
br label %79
79: ; preds = %77, %74
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 %62)
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 400)
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %71)
br label %83
83: ; preds = %79, %5
ret i32 0
}