#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 O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
char *msg_get() {
  int fd = 0;
  int len = 0;
  char buf[100] = "";
  fd = open("../../www/cgi-bin/msg_lognt", O_RDONLY);
  len = read(fd, buf, 100);
  close(fd);
  fd = open("../../www/cgi-bin/msg_lognt", O_WRONLY | O_TRUNC);
  close(fd);
  if (len > 0) {
    printf("%s\n", buf);
  }
  return buf;
}


x86 assembly (clang, -O0):
<msg_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
lea    0xe7a(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x64,%edx
call   1060 <read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <close@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
mov    0x2e3e(%rip),%rax
or     (%rax),%esi
lea    0xe3d(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <close@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11ed <msg_get+0x9d>
lea    -0x70(%rbp),%rsi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msg_get>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    0xe80(%rip),%r14
mov    %r14,%rdi
call   1060 <open@plt>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x64,%edx
call   1050 <read@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <close@plt>
mov    0x2e1f(%rip),%rax
mov    0x2e48(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r14,%rdi
call   1060 <open@plt>
mov    %eax,%edi
call   1040 <close@plt>
test   %ebx,%ebx
jle    11d6 <msg_get+0x96>
lea    0xe4e(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
mov    %rsp,%rax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"../../www/cgi-bin/msg_lognt\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i8* @msg_get() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%4 = bitcast [100 x i8]* %3 to i8*
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = call i32 @read(i32 %7, i8* %8, i32 100)
store i32 %9, i32* %2
%10 = load i32, i32* %1
%11 = call i32 @close(i32 %10)
%12 = load i32, i32* @O_WRONLY
%13 = load i32, i32* @O_TRUNC
%14 = or i32 %12, %13
%15 = call i32 @open(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 %15, i32* %1
%16 = load i32, i32* %1
%17 = call i32 @close(i32 %16)
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %0
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
ret i8* %24
}

LLVM IR (-O2):
@.str = [28 x i8] c"../../www/cgi-bin/msg_lognt\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i8* @msg_get() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 @read(i32 %4, i8* %2, i32 100)
%6 = tail call i32 @close(i32 %4)
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_TRUNC
%9 = or i32 %8, %7
%10 = tail call i32 @open(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @close(i32 %10)
%12 = icmp sgt i32 %5, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %15
15: ; preds = %13, %0
ret i8* %2
}