#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 /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int desas3(int adr, int *codes, char *ligne) {
  int a;
  char buf[40];
  if (codes[0] & 4)
    strcpy(ligne, "GOC    ");
  else
    strcpy(ligne, "GONC   ");
  a = codes[0] >> 3;
  if (a > 63)
    a -= 128;
  sprintf(buf, "%04X", adr + a);
  strcat(ligne, buf);
  return (1);
}


x86 assembly (clang, -O0):
<desas3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     116a <desas3+0x3a>
mov    -0x18(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1030 <strcpy@plt>
jmp    117a <desas3+0x4a>
mov    -0x18(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x3,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x3f,-0x1c(%rbp)
jle    119b <desas3+0x6b>
mov    -0x1c(%rbp),%eax
sub    $0x80,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x4(%rbp),%edx
add    -0x1c(%rbp),%edx
lea    0xe64(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <strcat@plt>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<desas3>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
testb  $0x4,(%rsi)
lea    0xebe(%rip),%rax
lea    0xeaf(%rip),%rsi
cmove  %rax,%rsi
mov    %rdx,%rdi
call   1030 <strcpy@plt>
mov    (%rbx),%eax
mov    %eax,%ecx
sar    $0x3,%ecx
lea    -0x80(%rcx),%edx
cmp    $0x200,%eax
cmovl  %ecx,%edx
add    %ebp,%edx
lea    0xe98(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcat@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"GOC \00"
@.str.1 = [8 x i8] c"GONC \00"
@.str.2 = [5 x i8] c"%04X\00"
define i32 @desas3(i32 %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [40 x i8]
store i32 %0, i32* %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%9 = load i32*, i32** %5
%10 = getelementptr inbounds i32, i32* %9, i64 0
%11 = load i32, i32* %10
%12 = and i32 %11, 4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %20
17: ; preds = %3
%18 = load i8*, i8** %6
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %17, %14
%21 = load i32*, i32** %5
%22 = getelementptr inbounds i32, i32* %21, i64 0
%23 = load i32, i32* %22
%24 = ashr i32 %23, 3
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp sgt i32 %25, 63
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i32, i32* %7
%29 = sub nsw i32 %28, 128
store i32 %29, i32* %7
br label %30
30: ; preds = %27, %20
%31 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%32 = load i32, i32* %4
%33 = load i32, i32* %7
%34 = add nsw i32 %32, %33
%35 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i8*, i8** %6
%37 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%38 = call i32 @strcat(i8* %36, i8* %37)
ret i32 1
}

LLVM IR (-O2):
@.str = [8 x i8] c"GOC \00"
@.str.1 = [8 x i8] c"GONC \00"
@.str.2 = [5 x i8] c"%04X\00"
define i32 @desas3(i32 %0, i32* nocapture %1, i8* %2) {
%4 = alloca [40 x i8]
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* %1
%7 = and i32 %6, 4
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0)
%10 = tail call i32 @strcpy(i8* %2, i8* %9)
%11 = load i32, i32* %1
%12 = ashr i32 %11, 3
%13 = icmp sgt i32 %11, 511
%14 = add nsw i32 %12, -128
%15 = select i1 %13, i32 %14, i32 %12
%16 = add nsw i32 %15, %0
%17 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = call i32 @strcat(i8* %2, i8* %5)
ret i32 1
}