#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 {
  unsigned short ws_row;
  unsigned short ws_col;
  unsigned short ws_xpixel;
  unsigned short ws_ypixel;
};

/* Variables and functions */
scalar_t__ atoi(char *);
int winsize_unpack(struct winsize *w, char *buf) {
  buf[4] = buf[9] = buf[14] = buf[19] = 0;
  w->ws_row = (unsigned short int)atoi(buf);
  w->ws_col = (unsigned short int)atoi(buf + 5);
  w->ws_xpixel = (unsigned short int)atoi(buf + 10);
  w->ws_ypixel = (unsigned short int)atoi(buf + 15);
}


x86 assembly (clang, -O0):
<winsize_unpack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,0x13(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0xe(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x9(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <atoi@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x18(%rbp),%rdi
add    $0x5,%rdi
call   1030 <atoi@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,0x2(%rax)
mov    -0x18(%rbp),%rdi
add    $0xa,%rdi
call   1030 <atoi@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,0x4(%rax)
mov    -0x18(%rbp),%rdi
add    $0xf,%rdi
call   1030 <atoi@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,0x6(%rax)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<winsize_unpack>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movb   $0x0,0x13(%rsi)
movb   $0x0,0xe(%rsi)
movb   $0x0,0x9(%rsi)
movb   $0x0,0x4(%rsi)
mov    %rsi,%rdi
call   1030 <atoi@plt>
mov    %ax,(%r14)
lea    0x5(%rbx),%rdi
call   1030 <atoi@plt>
mov    %ax,0x2(%r14)
lea    0xa(%rbx),%rdi
call   1030 <atoi@plt>
mov    %ax,0x4(%r14)
add    $0xf,%rbx
mov    %rbx,%rdi
call   1030 <atoi@plt>
mov    %ax,0x6(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.winsize = type { i16, i16, i16, i16 }
define i32 @winsize_unpack(%struct.winsize* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.winsize*
%5 = alloca i8*
store %struct.winsize* %0, %struct.winsize** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %6, i64 19
store i8 0, i8* %7
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 14
store i8 0, i8* %9
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 9
store i8 0, i8* %11
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 4
store i8 0, i8* %13
%14 = load i8*, i8** %5
%15 = call i64 @atoi(i8* %14)
%16 = trunc i64 %15 to i16
%17 = load %struct.winsize*, %struct.winsize** %4
%18 = getelementptr inbounds %struct.winsize, %struct.winsize* %17, i32 0, i32 0
store i16 %16, i16* %18
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 5
%21 = call i64 @atoi(i8* %20)
%22 = trunc i64 %21 to i16
%23 = load %struct.winsize*, %struct.winsize** %4
%24 = getelementptr inbounds %struct.winsize, %struct.winsize* %23, i32 0, i32 1
store i16 %22, i16* %24
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i64 10
%27 = call i64 @atoi(i8* %26)
%28 = trunc i64 %27 to i16
%29 = load %struct.winsize*, %struct.winsize** %4
%30 = getelementptr inbounds %struct.winsize, %struct.winsize* %29, i32 0, i32 2
store i16 %28, i16* %30
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 15
%33 = call i64 @atoi(i8* %32)
%34 = trunc i64 %33 to i16
%35 = load %struct.winsize*, %struct.winsize** %4
%36 = getelementptr inbounds %struct.winsize, %struct.winsize* %35, i32 0, i32 3
store i16 %34, i16* %36
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
%struct.winsize = type { i16, i16, i16, i16 }
define i32 @winsize_unpack(%struct.winsize* nocapture writeonly %0, i8* nocapture %1) {
%3 = getelementptr inbounds i8, i8* %1, i64 19
store i8 0, i8* %3
%4 = getelementptr inbounds i8, i8* %1, i64 14
store i8 0, i8* %4
%5 = getelementptr inbounds i8, i8* %1, i64 9
store i8 0, i8* %5
%6 = getelementptr inbounds i8, i8* %1, i64 4
store i8 0, i8* %6
%7 = tail call i64 @atoi(i8* %1)
%8 = trunc i64 %7 to i16
%9 = getelementptr inbounds %struct.winsize, %struct.winsize* %0, i64 0, i32 0
store i16 %8, i16* %9
%10 = getelementptr inbounds i8, i8* %1, i64 5
%11 = tail call i64 @atoi(i8* %10)
%12 = trunc i64 %11 to i16
%13 = getelementptr inbounds %struct.winsize, %struct.winsize* %0, i64 0, i32 1
store i16 %12, i16* %13
%14 = getelementptr inbounds i8, i8* %1, i64 10
%15 = tail call i64 @atoi(i8* %14)
%16 = trunc i64 %15 to i16
%17 = getelementptr inbounds %struct.winsize, %struct.winsize* %0, i64 0, i32 2
store i16 %16, i16* %17
%18 = getelementptr inbounds i8, i8* %1, i64 15
%19 = tail call i64 @atoi(i8* %18)
%20 = trunc i64 %19 to i16
%21 = getelementptr inbounds %struct.winsize, %struct.winsize* %0, i64 0, i32 3
store i16 %20, i16* %21
ret i32 undef
}