#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 */
char *calloc(size_t, int);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char const *, char *);
int /*<<< orphan*/ stdin;
int strlen(char const *);
int /*<<< orphan*/ system(char *);
int main(void) {
  size_t nbytes = 0;
  char *line = NULL;
  const char *python = "python2 -c 'print ";
  while (getline(&line, &nbytes, stdin) != -1) {
    line[strlen(line) - 1] = '\0';
    size_t bufsize = strlen(python) + strlen(line) + 2;
    char *buf = calloc(bufsize, sizeof(*buf));
    snprintf(buf, bufsize, "%s%s'", python, line);
    system(buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
je     121b <main+0xcb>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe0b(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <system@plt>
jmp    117a <main+0x2a>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2e71(%rip),%r14
mov    (%r14),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
je     1225 <main+0xd5>
lea    0xe67(%rip),%r13
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
call   1030 <strlen@plt>
add    %ebx,%eax
add    $0x2,%eax
movslq %eax,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%r8
mov    %rax,%rdi
mov    %rbx,%rsi
lea    0xe11(%rip),%rdx
mov    %r13,%rcx
call   1050 <snprintf@plt>
mov    %rbp,%rdi
call   1040 <system@plt>
mov    (%r14),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
jne    11b0 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"python2 -c 'print \00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"%s%s'\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i32 0, i32* %1
store i64 0, i64* %2
store i8* null, i8** %3
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %4
br label %7
7: ; preds = %11, %0
%8 = load i32, i32* @stdin
%9 = call i32 @getline(i8** %3, i64* %2, i32 %8)
%10 = icmp ne i32 %9, -1
br i1 %10, label %11, label %34
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @strlen(i8* %13)
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %12, i64 %16
store i8 0, i8* %17
%18 = load i8*, i8** %4
%19 = call i32 @strlen(i8* %18)
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = add nsw i32 %19, %21
%23 = add nsw i32 %22, 2
%24 = sext i32 %23 to i64
store i64 %24, i64* %5
%25 = load i64, i64* %5
%26 = call i8* @calloc(i64 %25, i32 1)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = load i64, i64* %5
%29 = load i8*, i8** %4
%30 = load i8*, i8** %3
%31 = call i32 @snprintf(i8* %27, i64 %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30)
%32 = load i8*, i8** %6
%33 = call i32 @system(i8* %32)
br label %7
34: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"python2 -c 'print \00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"%s%s'\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i8*
%3 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = load i32, i32* @stdin
%6 = call i32 @getline(i8** %2, i64* %1, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %27, label %8
8: ; preds = %0, %8
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %10, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
store i8 0, i8* %13
%14 = call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
%17 = add i32 %14, 2
%18 = add i32 %17, %16
%19 = sext i32 %18 to i64
%20 = call i8* @calloc(i64 %19, i32 1)
%21 = load i8*, i8** %2
%22 = call i32 @snprintf(i8* %20, i64 %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @system(i8* %20)
%24 = load i32, i32* @stdin
%25 = call i32 @getline(i8** %2, i64* %1, i32 %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %8
27: ; preds = %8, %0
ret i32 0
}