#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 */
int getISO(char *, int, int *);
int strlen(char *);
void ISOdecode(char s[], char out[]) {
  int i, j, len;
  int code;
  len = strlen(s);
  i = 0;
  j = 0;
  while (i < len) {
    i = getISO(s, i, &code);
    out[j] = (char)code;
    j = j + 1;
  };
  out[j] = '\0';
}


x86 assembly (clang, -O0):
<ISOdecode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1187 <ISOdecode+0x67>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   1040 <getISO@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <ISOdecode+0x2a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ISOdecode>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %eax,%ebp
xor    %eax,%eax
test   %ebp,%ebp
jle    1170 <ISOdecode+0x50>
lea    0xc(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %eax,%esi
mov    %r15,%rdx
call   1040 <getISO@plt>
movzbl 0xc(%rsp),%ecx
mov    %cl,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %ebp,%eax
jl     1150 <ISOdecode+0x30>
mov    %ebx,%eax
movb   $0x0,(%r14,%rax,1)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ISOdecode(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %7
store i32 0, i32* %5
store i32 0, i32* %6
br label %11
11: ; preds = %15, %2
%12 = load i32, i32* %5
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = load i32, i32* %5
%18 = call i32 @getISO(i8* %16, i32 %17, i32* %8)
store i32 %18, i32* %5
%19 = load i32, i32* %8
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 %20, i8* %24
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %11
27: ; preds = %11
%28 = load i8*, i8** %4
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 0, i8* %31
ret void
}

LLVM IR (-O2):
define void @ISOdecode(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %2, %7
%8 = phi i64 [ %14, %7 ], [ 0, %2 ]
%9 = phi i32 [ %10, %7 ], [ 0, %2 ]
%10 = call i32 @getISO(i8* %0, i32 %9, i32* %3)
%11 = load i32, i32* %3
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds i8, i8* %1, i64 %8
store i8 %12, i8* %13
%14 = add nuw i64 %8, 1
%15 = icmp slt i32 %10, %5
br i1 %15, label %7, label %16
16: ; preds = %7
%17 = and i64 %14, 4294967295
br label %18
18: ; preds = %16, %2
%19 = phi i64 [ 0, %2 ], [ %17, %16 ]
%20 = getelementptr inbounds i8, i8* %1, i64 %19
store i8 0, i8* %20
ret void
}