#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*/ O_RDWR;
int /*<<< orphan*/ assert(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ read(int, char *, int);
int main(int argc, char *argv[]) {
  assert(argc > 1);
  char buf[100];
  char i = 0;
  printf("Input string: %s\n", argv[1]);
  int fp = open("/dev/my_driver", O_RDWR);
  read(fp, buf, 100);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movb   $0x0,-0x81(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
lea    0xe84(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x64,%edx
call   1040 <read@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%rbx
xor    %eax,%eax
cmp    $0x2,%edi
setge  %al
mov    %eax,%edi
call   1050 <assert@plt>
mov    0x8(%rbx),%rsi
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
lea    0xe9b(%rip),%rdi
call   1060 <open@plt>
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x64,%edx
call   1040 <read@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Input string: %s\0A\00"
@.str.1 = [15 x i8] c"/dev/my_driver\00"
@O_RDWR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [100 x i8]
%6 = alloca i8
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 1
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
store i8 0, i8* %6
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @O_RDWR
%17 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %16)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%20 = call i32 @read(i32 %18, i8* %19, i32 100)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Input string: %s\0A\00"
@.str.1 = [15 x i8] c"/dev/my_driver\00"
@O_RDWR = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = icmp sgt i32 %0, 1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @O_RDWR
%12 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = call i32 @read(i32 %12, i8* %7, i32 100)
ret i32 0
}