#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*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *fp;
  char path[1035];
  fp = popen(
      "python3.6 -c 'from random import choice, randint;from string import "
      "ascii_letters, digits; print(*[choice(ascii_letters+digits) for _ in "
      "range(randint(10 ,20))], sep=str())'",
      "r");
  if (fp == NULL) {
    printf("Failed to run the command");
    exit(1);
  }
  fgets(path, 1000, fp);
  printf("%s\n", path);
  pclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xf3e(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119c <main+0x4c>
lea    0xf25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
lea    -0x420(%rbp),%rsi
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <pclose@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x418,%rsp
lea    0xe8f(%rip),%rdi
lea    0xf36(%rip),%rsi
call   1070 <popen@plt>
test   %rax,%rax
je     11b5 <main+0x55>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x3e8,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <pclose@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
ret
lea    0xef4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [174 x i8] c"python3.6 -c 'from random import choice, randint;from string import ascii_letters, digits; print(*[choice(ascii_letters+digits) for _ in range(randint(10 ,20))], sep=str())'\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [26 x i8] c"Failed to run the command\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [1035 x i8]
store i32 0, i32* %1
%4 = call i32* @popen(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = getelementptr inbounds [1035 x i8], [1035 x i8]* %3, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i32 @fgets(i8* %11, i32 1000, i32* %12)
%14 = getelementptr inbounds [1035 x i8], [1035 x i8]* %3, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = load i32*, i32** %2
%17 = call i32 @pclose(i32* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [174 x i8] c"python3.6 -c 'from random import choice, randint;from string import ascii_letters, digits; print(*[choice(ascii_letters+digits) for _ in range(randint(10 ,20))], sep=str())'\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [26 x i8] c"Failed to run the command\00"
define i32 @main() {
%1 = alloca [1035 x i8]
%2 = getelementptr inbounds [1035 x i8], [1035 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @popen(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = call i32 @fgets(i8* %2, i32 1000, i32* %3)
%10 = call i32 @puts(i8* %2)
%11 = call i32 @pclose(i32* %3)
ret i32 0
}