#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*/ close(int);
char *inet_addr(char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argcv[]) {
  printf("El programa se llama %s\n", argcv[0]);
  int fd;
  char *buffer = "Hola\n";
  char *fichero = "prueba.txt";
  buffer = "Adios\n";
  printf("El buffer tiene : %s", buffer);
  printf("El número de argumentos es %d\n", argc);
  if ((fd = open(fichero, O_RDWR)) == -1) {
    printf("Error al abrir el fichero %s\n", fichero);
  } else {
    int readbytes = strlen(buffer);
    write(fd, buffer, readbytes);
    close(fd);
  }
  printf("La dirección para \"192.168.1.1\" en unsing long es: %lu\n",
         inet_addr("255.255.255.255"));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe87(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe82(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe82(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1204 <main+0xa4>
mov    -0x28(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1227 <main+0xc7>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
lea    0xe8f(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %rax,%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    (%rsi),%rsi
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xead(%rip),%rdi
lea    0xe9f(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xead(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
lea    0xe6d(%rip),%rdi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     11dc <main+0x7c>
mov    %eax,%ebx
lea    0xe65(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1060 <close@plt>
jmp    11f1 <main+0x91>
lea    0xe7d(%rip),%rdi
lea    0xe2f(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebf(%rip),%rdi
call   1070 <inet_addr@plt>
lea    0xe7a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"El programa se llama %s\0A\00"
@.str.1 = [6 x i8] c"Hola\0A\00"
@.str.2 = [11 x i8] c"prueba.txt\00"
@.str.3 = [7 x i8] c"Adios\0A\00"
@.str.4 = [21 x i8] c"El buffer tiene : %s\00"
@.str.5 = [32 x i8] c"El n\C3\BAmero de argumentos es %d\0A\00"
@O_RDWR = global i32 0
@.str.6 = [30 x i8] c"Error al abrir el fichero %s\0A\00"
@.str.7 = [57 x i8] c"La direcci\C3\B3n para \22192.168.1.1\22 en unsing long es: %lu\0A\00"
@.str.8 = [16 x i8] c"255.255.255.255\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %12)
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %7
%14 = load i8*, i8** %7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %16)
%18 = load i8*, i8** %8
%19 = load i32, i32* @O_RDWR
%20 = call i32 @open(i8* %18, i32 %19)
store i32 %20, i32* %6
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i8*, i8** %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %23)
br label %34
25: ; preds = %2
%26 = load i8*, i8** %7
%27 = call i32 @strlen(i8* %26)
store i32 %27, i32* %9
%28 = load i32, i32* %6
%29 = load i8*, i8** %7
%30 = load i32, i32* %9
%31 = call i32 @write(i32 %28, i8* %29, i32 %30)
%32 = load i32, i32* %6
%33 = call i32 @close(i32 %32)
br label %34
34: ; preds = %25, %22
%35 = call i8* @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), i8* %35)
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [25 x i8] c"El programa se llama %s\0A\00"
@.str.2 = [11 x i8] c"prueba.txt\00"
@.str.3 = [7 x i8] c"Adios\0A\00"
@.str.4 = [21 x i8] c"El buffer tiene : %s\00"
@.str.5 = [32 x i8] c"El n\C3\BAmero de argumentos es %d\0A\00"
@O_RDWR = global i32 0
@.str.6 = [30 x i8] c"Error al abrir el fichero %s\0A\00"
@.str.7 = [57 x i8] c"La direcci\C3\B3n para \22192.168.1.1\22 en unsing long es: %lu\0A\00"
@.str.8 = [16 x i8] c"255.255.255.255\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %0)
%7 = load i32, i32* @O_RDWR
%8 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %16
12: ; preds = %2
%13 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = tail call i32 @close(i32 %8)
br label %16
16: ; preds = %12, %10
%17 = tail call i8* @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), i8* %17)
ret i32 0
}