#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 */
struct winsize {
  scalar_t__ ws_ypixel;
  scalar_t__ ws_xpixel;
  scalar_t__ ws_col;
  scalar_t__ ws_row;
};

/* Variables and functions */
int sprintf(char *, char *, int, int, int, int);
int winsize_pack(const struct winsize *w, char *buf) {
  int t;
  t = sprintf(buf, "%04d %04d %04d %04d ", (int)w->ws_row, (int)w->ws_col,
              (int)w->ws_xpixel, (int)w->ws_ypixel);
  return t;
}


x86 assembly (clang, -O0):
<winsize_pack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%r8d
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%r9d
lea    0xeac(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<winsize_pack>:
mov    %rsi,%rax
mov    0x18(%rdi),%edx
mov    0x10(%rdi),%ecx
mov    (%rdi),%r9d
mov    0x8(%rdi),%r8d
lea    0xed9(%rip),%rsi
mov    %rax,%rdi
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
%struct.winsize = type { i64, i64, i64, i64 }
@.str = [21 x i8] c"%04d %04d %04d %04d \00"
define i32 @winsize_pack(%struct.winsize* %0, i8* %1) {
%3 = alloca %struct.winsize*
%4 = alloca i8*
%5 = alloca i32
store %struct.winsize* %0, %struct.winsize** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = load %struct.winsize*, %struct.winsize** %3
%8 = getelementptr inbounds %struct.winsize, %struct.winsize* %7, i32 0, i32 3
%9 = load i64, i64* %8
%10 = trunc i64 %9 to i32
%11 = load %struct.winsize*, %struct.winsize** %3
%12 = getelementptr inbounds %struct.winsize, %struct.winsize* %11, i32 0, i32 2
%13 = load i64, i64* %12
%14 = trunc i64 %13 to i32
%15 = load %struct.winsize*, %struct.winsize** %3
%16 = getelementptr inbounds %struct.winsize, %struct.winsize* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = load %struct.winsize*, %struct.winsize** %3
%20 = getelementptr inbounds %struct.winsize, %struct.winsize* %19, i32 0, i32 0
%21 = load i64, i64* %20
%22 = trunc i64 %21 to i32
%23 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %14, i32 %18, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
%struct.winsize = type { i64, i64, i64, i64 }
@.str = [21 x i8] c"%04d %04d %04d %04d \00"
define i32 @winsize_pack(%struct.winsize* nocapture %0, i8* nocapture writeonly %1) {
%3 = getelementptr inbounds %struct.winsize, %struct.winsize* %0, i64 0, i32 3
%4 = load i64, i64* %3
%5 = trunc i64 %4 to i32
%6 = getelementptr inbounds %struct.winsize, %struct.winsize* %0, i64 0, i32 2
%7 = load i64, i64* %6
%8 = trunc i64 %7 to i32
%9 = getelementptr inbounds %struct.winsize, %struct.winsize* %0, i64 0, i32 1
%10 = load i64, i64* %9
%11 = trunc i64 %10 to i32
%12 = getelementptr inbounds %struct.winsize, %struct.winsize* %0, i64 0, i32 0
%13 = load i64, i64* %12
%14 = trunc i64 %13 to i32
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %8, i32 %11, i32 %14)
ret i32 %15
}