#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ usage(char *);
void getMemoryAddress(char *chan, char *progName) {
  int c, addr;
  c = atoi(chan);
  if (c >= 0 && c <= 199) {
    addr = 0x0C00 + 0x40 * c;
    printf("Memory channel %d corresponds to address %#06x\n", c, addr);
  } else {
    printf("Invalid memory channel %d\n", c);
    usage(progName);
  }
}


x86 assembly (clang, -O0):
<getMemoryAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     118a <getMemoryAddress+0x5a>
cmpl   $0xc7,-0x14(%rbp)
jg     118a <getMemoryAddress+0x5a>
mov    -0x14(%rbp),%eax
shl    $0x6,%eax
add    $0xc00,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a4 <getMemoryAddress+0x74>
mov    -0x14(%rbp),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <usage@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMemoryAddress>:
push   %rbx
mov    %rsi,%rbx
call   1050 <atoi@plt>
cmp    $0xc7,%eax
ja     115c <getMemoryAddress+0x2c>
mov    %eax,%edx
shl    $0x6,%edx
add    $0xc00,%edx
lea    0xeae(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <usage@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"Memory channel %d corresponds to address %x\0A\00"
@.str.1 = [27 x i8] c"Invalid memory channel %d\0A\00"
define void @getMemoryAddress(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @atoi(i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 199
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %5
%16 = mul nsw i32 64, %15
%17 = add nsw i32 3072, %16
store i32 %17, i32* %6
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19)
br label %26
21: ; preds = %11, %2
%22 = load i32, i32* %5
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i8*, i8** %4
%25 = call i32 @usage(i8* %24)
br label %26
26: ; preds = %21, %14
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"Memory channel %d corresponds to address %x\0A\00"
@.str.1 = [27 x i8] c"Invalid memory channel %d\0A\00"
define void @getMemoryAddress(i8* nocapture %0, i8* %1) {
%3 = tail call i32 @atoi(i8* %0)
%4 = icmp ult i32 %3, 200
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = shl nuw nsw i32 %3, 6
%7 = add nuw nsw i32 %6, 3072
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %7)
br label %12
9: ; preds = %2
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%11 = tail call i32 @usage(i8* %1)
br label %12
12: ; preds = %9, %5
ret void
}