#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *malloc(int);
int /*<<< orphan*/ mkstemp(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ system(char *);
char *GFX_ReadStringFromPythonCommand(char *pythoncommand) {
  FILE *file;
  char filename[50];
  char temp[500];
  char *ret = malloc(500);
  sprintf(filename, "/tmp/radiumipctempfileXXXXXX");
  mkstemp(filename);
  printf("1 -%s- -%s-\n", filename, pythoncommand);
  sprintf(temp, pythoncommand, filename);
  printf("2 -%s- -%s-\n", filename, temp);
  printf("3 -%s-\n", filename);
  file = fopen(filename, "r");
  if (file == NULL)
    printf("Oops file is null -%s-\n", filename);
  fgets(ret, 499, file);
  fclose(file);
  printf("Tried to read -%s-\n", ret);
  sprintf(temp, "rm %s", filename);
  system(temp);
  return ret;
}


x86 assembly (clang, -O0):
<GFX_ReadStringFromPythonCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1f4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x258(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x50(%rbp),%rdi
call   1080 <mkstemp@plt>
lea    -0x50(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x250(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x50(%rbp),%rsi
lea    -0x250(%rbp),%rdx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1243 <GFX_ReadStringFromPythonCommand+0xc3>
lea    -0x50(%rbp),%rsi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x258(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1f3,%esi
call   1060 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x258(%rbp),%rsi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x250(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xde5(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x250(%rbp),%rdi
call   1040 <system@plt>
mov    -0x258(%rbp),%rax
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GFX_ReadStringFromPythonCommand>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %rdi,%r15
mov    $0x1f4,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
movups 0xe5b(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe5d(%rip),%xmm0
movups %xmm0,0xd(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <mkstemp@plt>
lea    0xe56(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x40(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
lea    0xe3a(%rip),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe33(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2a(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1236 <GFX_ReadStringFromPythonCommand+0xb6>
lea    0xe15(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x1f3,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe04(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe07(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r14,%rax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"/tmp/radiumipctempfileXXXXXX\00"
@.str.1 = [13 x i8] c"1 -%s- -%s-\0A\00"
@.str.2 = [13 x i8] c"2 -%s- -%s-\0A\00"
@.str.3 = [8 x i8] c"3 -%s-\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [24 x i8] c"Oops file is null -%s-\0A\00"
@.str.6 = [20 x i8] c"Tried to read -%s-\0A\00"
@.str.7 = [6 x i8] c"rm %s\00"
define i8* @GFX_ReadStringFromPythonCommand(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [50 x i8]
%5 = alloca [500 x i8]
%6 = alloca i8*
store i8* %0, i8** %2
%7 = call i8* @malloc(i32 500)
store i8* %7, i8** %6
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%11 = call i32 @mkstemp(i8* %10)
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%13 = load i8*, i8** %2
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %13)
%15 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%16 = load i8*, i8** %2
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* %16, i8* %17)
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %20)
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %25, i32** %3
%26 = load i32*, i32** %3
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %31
28: ; preds = %1
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %1
%32 = load i8*, i8** %6
%33 = load i32*, i32** %3
%34 = call i32 @fgets(i8* %32, i32 499, i32* %33)
%35 = load i32*, i32** %3
%36 = call i32 @fclose(i32* %35)
%37 = load i8*, i8** %6
%38 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%41 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%43 = call i32 @system(i8* %42)
%44 = load i8*, i8** %6
ret i8* %44
}

LLVM IR (-O2):
@.str = [29 x i8] c"/tmp/radiumipctempfileXXXXXX\00"
@.str.1 = [13 x i8] c"1 -%s- -%s-\0A\00"
@.str.2 = [13 x i8] c"2 -%s- -%s-\0A\00"
@.str.3 = [8 x i8] c"3 -%s-\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [24 x i8] c"Oops file is null -%s-\0A\00"
@.str.6 = [20 x i8] c"Tried to read -%s-\0A\00"
@.str.7 = [6 x i8] c"rm %s\00"
define i8* @GFX_ReadStringFromPythonCommand(i8* %0) {
%2 = alloca [50 x i8]
%3 = alloca [500 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%6 = tail call dereferenceable_or_null(500) i8* @malloc(i32 500)
%7 = call i32 @mkstemp(i8* %4)
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %0)
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) %0, i8* %4)
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %5)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%12 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %16
16: ; preds = %14, %1
%17 = call i32 @fgets(i8* %6, i32 499, i32* %12)
%18 = call i32 @fclose(i32* %12)
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %4)
%21 = call i32 @system(i8* %5)
ret i8* %6
}