#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ read_cvt(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ system(char *);
char *cvt(int width, int height) {
  char cmd[256];
  sprintf(cmd,
          "cvt %d %d | grep Modeline | awk -F' ' '{print $3, $4, $5, $6, $7, "
          "$8, $9, $10, $11, $12, $13}' > /tmp/gxrandr_cvt",
          width, height);
  system(cmd);
  char *result = (char *)malloc(sizeof(char) * 128);
  read_cvt(result);
  system("rm -f /tmp/gxrandr_cvt");
  return result;
}


x86 assembly (clang, -O0):
<cvt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe9b(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <system@plt>
mov    $0x80,%edi
call   1050 <malloc@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1040 <read_cvt@plt>
lea    0xed8(%rip),%rdi
call   1030 <system@plt>
mov    -0x118(%rbp),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cvt>:
push   %rbx
sub    $0x100,%rsp
mov    %esi,%ecx
mov    %edi,%edx
lea    0xead(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    $0x80,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <read_cvt@plt>
lea    0xef0(%rip),%rdi
call   1030 <system@plt>
mov    %rbx,%rax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [114 x i8] c"cvt %d %d | grep Modeline | awk -F' ' '{print $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13}' > /tmp/gxrandr_cvt\00"
@.str.1 = [23 x i8] c"rm -f /tmp/gxrandr_cvt\00"
define i8* @cvt(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%12 = call i32 @system(i8* %11)
%13 = call i64 @malloc(i32 128)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = call i32 @read_cvt(i8* %15)
%17 = call i32 @system(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8*, i8** %6
ret i8* %18
}

LLVM IR (-O2):
@.str = [114 x i8] c"cvt %d %d | grep Modeline | awk -F' ' '{print $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13}' > /tmp/gxrandr_cvt\00"
@.str.1 = [23 x i8] c"rm -f /tmp/gxrandr_cvt\00"
define i8* @cvt(i32 %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([114 x i8], [114 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%6 = call i32 @system(i8* %4)
%7 = tail call i64 @malloc(i32 128)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @read_cvt(i8* %8)
%10 = tail call i32 @system(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
ret i8* %8
}