#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*/ memcpy(unsigned char *, char *, int);
void makegif(unsigned char *im, unsigned char *gif) {
  memcpy(gif,
         "GIF89a"
         "\xc8\0\x46\0"
         "\x83"
         "\0\0"
         "\x00\x00\x00"
         "\x10\x10\x10"
         "\x20\x20\x20"
         "\x30\x30\x30"
         "\x40\x40\x40"
         "\x50\x50\x50"
         "\x60\x60\x60"
         "\x70\x70\x70"
         "\x80\x80\x80"
         "\x90\x90\x90"
         "\xa0\xa0\xa0"
         "\xb0\xb0\xb0"
         "\xc0\xc0\xc0"
         "\xd0\xd0\xd0"
         "\xe0\xe0\xe0"
         "\xff\xff\xff"
         ","
         "\0\0\0\0"
         "\xc8\0\x46\0"
         "\0"
         "\x04",
         13 + 48 + 10 + 1);
  int x, y;
  unsigned char *i = im;
  unsigned char *p = gif + 13 + 48 + 10 + 1;
  for (y = 0; y < 70; y++) {
    *p++ = 250;
    for (x = 0; x < 50; x++) {
      unsigned char a = i[0] >> 4, b = i[1] >> 4, c = i[2] >> 4, d = i[3] >> 4;
      p[0] = 16 | (a << 5);
      p[1] = (a >> 3) | 64 | (b << 7);
      p[2] = b >> 1;
      p[3] = 1 | (c << 1);
      p[4] = 4 | (d << 3);
      i += 4;
      p += 5;
    }
  }
  memcpy(gif + 17646 - 4,
         "\x01"
         "\x11"
         "\x00"
         ";",
         4);
}


x86 assembly (clang, -O0):
<makegif>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
mov    $0x48,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0xd,%rax
add    $0x30,%rax
add    $0xa,%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x46,-0x18(%rbp)
jge    125d <makegif+0x14d>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xfa,(%rax)
movl   $0x0,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jge    124a <makegif+0x13a>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
sar    $0x4,%eax
mov    %al,-0x29(%rbp)
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
sar    $0x4,%eax
mov    %al,-0x2a(%rbp)
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%eax
sar    $0x4,%eax
mov    %al,-0x2b(%rbp)
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%eax
sar    $0x4,%eax
mov    %al,-0x2c(%rbp)
movzbl -0x29(%rbp),%eax
shl    $0x5,%eax
or     $0x10,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
movzbl -0x29(%rbp),%eax
sar    $0x3,%eax
or     $0x40,%eax
movzbl -0x2a(%rbp),%ecx
shl    $0x7,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x1(%rax)
movzbl -0x2a(%rbp),%eax
sar    $0x1,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x2(%rax)
movzbl -0x2b(%rbp),%eax
shl    $0x1,%eax
or     $0x1,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x3(%rax)
movzbl -0x2c(%rbp),%eax
shl    $0x3,%eax
or     $0x4,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <makegif+0x6f>
jmp    124f <makegif+0x13f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115c <makegif+0x4c>
mov    -0x10(%rbp),%rdi
add    $0x44ee,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xdd6(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makegif>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xede(%rip),%rsi
mov    %r14,%rdi
mov    $0x48,%edx
call   1030 <memcpy@plt>
lea    0x48(%r14),%r9
xor    %r8d,%r8d
cs nopw 0x0(%rax,%rax,1)
movb   $0xfa,(%r9)
mov    $0x1,%edx
nopl   0x0(%rax)
movzbl (%r15),%esi
movzbl 0x1(%r15),%edi
movzbl 0x2(%r15),%eax
movzbl 0x3(%r15),%ecx
lea    (%rsi,%rsi,1),%ebx
and    $0xe0,%bl
or     $0x10,%bl
mov    %bl,(%r9,%rdx,1)
shr    $0x7,%sil
lea    0x0(,%rdi,8),%ebx
and    $0x80,%bl
or     %sil,%bl
or     $0x40,%bl
mov    %bl,0x1(%r9,%rdx,1)
shr    $0x5,%dil
mov    %dil,0x2(%r9,%rdx,1)
shr    $0x3,%al
or     $0x1,%al
mov    %al,0x3(%r9,%rdx,1)
shr    %cl
and    $0x78,%cl
or     $0x4,%cl
mov    %cl,0x4(%r9,%rdx,1)
add    $0x4,%r15
add    $0x5,%rdx
cmp    $0xfb,%edx
jne    1150 <makegif+0x40>
add    $0x1,%r8d
add    %rdx,%r9
cmp    $0x46,%r8d
jne    1140 <makegif+0x30>
add    $0x44ea,%r14
lea    0xe71(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <memcpy@plt>

LLVM IR (-O0):
@.str = [73 x i8] c"GIF89a\C8\00F\00\83\00\00\00\00\00\10\10\10 000@@@PPP```ppp\80\80\80\90\90\90\A0\A0\A0\B0\B0\B0\C0\C0\C0\D0\D0\D0\E0\E0\E0\FF\FF\FF,\00\00\00\00\C8\00F\00\00\04\00"
@.str.1 = [5 x i8] c"\01\11\00;\00"
define void @makegif(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%13 = load i8*, i8** %4
%14 = call i32 @memcpy(i8* %13, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 72)
%15 = load i8*, i8** %3
store i8* %15, i8** %7
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 13
%18 = getelementptr inbounds i8, i8* %17, i64 48
%19 = getelementptr inbounds i8, i8* %18, i64 10
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %20, i8** %8
store i32 0, i32* %6
br label %21
21: ; preds = %101, %2
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 70
br i1 %23, label %24, label %104
24: ; preds = %21
%25 = load i8*, i8** %8
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %8
store i8 -6, i8* %25
store i32 0, i32* %5
br label %27
27: ; preds = %97, %24
%28 = load i32, i32* %5
%29 = icmp slt i32 %28, 50
br i1 %29, label %30, label %100
30: ; preds = %27
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = ashr i32 %34, 4
%36 = trunc i32 %35 to i8
store i8 %36, i8* %9
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = ashr i32 %40, 4
%42 = trunc i32 %41 to i8
store i8 %42, i8* %10
%43 = load i8*, i8** %7
%44 = getelementptr inbounds i8, i8* %43, i64 2
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = ashr i32 %46, 4
%48 = trunc i32 %47 to i8
store i8 %48, i8* %11
%49 = load i8*, i8** %7
%50 = getelementptr inbounds i8, i8* %49, i64 3
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = ashr i32 %52, 4
%54 = trunc i32 %53 to i8
store i8 %54, i8* %12
%55 = load i8, i8* %9
%56 = zext i8 %55 to i32
%57 = shl i32 %56, 5
%58 = or i32 16, %57
%59 = trunc i32 %58 to i8
%60 = load i8*, i8** %8
%61 = getelementptr inbounds i8, i8* %60, i64 0
store i8 %59, i8* %61
%62 = load i8, i8* %9
%63 = zext i8 %62 to i32
%64 = ashr i32 %63, 3
%65 = or i32 %64, 64
%66 = load i8, i8* %10
%67 = zext i8 %66 to i32
%68 = shl i32 %67, 7
%69 = or i32 %65, %68
%70 = trunc i32 %69 to i8
%71 = load i8*, i8** %8
%72 = getelementptr inbounds i8, i8* %71, i64 1
store i8 %70, i8* %72
%73 = load i8, i8* %10
%74 = zext i8 %73 to i32
%75 = ashr i32 %74, 1
%76 = trunc i32 %75 to i8
%77 = load i8*, i8** %8
%78 = getelementptr inbounds i8, i8* %77, i64 2
store i8 %76, i8* %78
%79 = load i8, i8* %11
%80 = zext i8 %79 to i32
%81 = shl i32 %80, 1
%82 = or i32 1, %81
%83 = trunc i32 %82 to i8
%84 = load i8*, i8** %8
%85 = getelementptr inbounds i8, i8* %84, i64 3
store i8 %83, i8* %85
%86 = load i8, i8* %12
%87 = zext i8 %86 to i32
%88 = shl i32 %87, 3
%89 = or i32 4, %88
%90 = trunc i32 %89 to i8
%91 = load i8*, i8** %8
%92 = getelementptr inbounds i8, i8* %91, i64 4
store i8 %90, i8* %92
%93 = load i8*, i8** %7
%94 = getelementptr inbounds i8, i8* %93, i64 4
store i8* %94, i8** %7
%95 = load i8*, i8** %8
%96 = getelementptr inbounds i8, i8* %95, i64 5
store i8* %96, i8** %8
br label %97
97: ; preds = %30
%98 = load i32, i32* %5
%99 = add nsw i32 %98, 1
store i32 %99, i32* %5
br label %27
100: ; preds = %27
br label %101
101: ; preds = %100
%102 = load i32, i32* %6
%103 = add nsw i32 %102, 1
store i32 %103, i32* %6
br label %21
104: ; preds = %21
%105 = load i8*, i8** %4
%106 = getelementptr inbounds i8, i8* %105, i64 17646
%107 = getelementptr inbounds i8, i8* %106, i64 -4
%108 = call i32 @memcpy(i8* %107, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
ret void
}

LLVM IR (-O2):
@.str = [73 x i8] c"GIF89a\C8\00F\00\83\00\00\00\00\00\10\10\10 000@@@PPP```ppp\80\80\80\90\90\90\A0\A0\A0\B0\B0\B0\C0\C0\C0\D0\D0\D0\E0\E0\E0\FF\FF\FF,\00\00\00\00\C8\00F\00\00\04\00"
@.str.1 = [5 x i8] c"\01\11\00;\00"
define void @makegif(i8* nocapture %0, i8* %1) {
%3 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 72)
%4 = getelementptr inbounds i8, i8* %1, i64 72
br label %5
5: ; preds = %2, %43
%6 = phi i32 [ 0, %2 ], [ %44, %43 ]
%7 = phi i8* [ %0, %2 ], [ %39, %43 ]
%8 = phi i8* [ %4, %2 ], [ %40, %43 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
store i8 -6, i8* %8
br label %10
10: ; preds = %5, %10
%11 = phi i32 [ 0, %5 ], [ %41, %10 ]
%12 = phi i8* [ %7, %5 ], [ %39, %10 ]
%13 = phi i8* [ %9, %5 ], [ %40, %10 ]
%14 = load i8, i8* %12
%15 = getelementptr inbounds i8, i8* %12, i64 1
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %12, i64 2
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %12, i64 3
%20 = load i8, i8* %19
%21 = shl i8 %14, 1
%22 = and i8 %21, -32
%23 = or i8 %22, 16
store i8 %23, i8* %13
%24 = lshr i8 %14, 7
%25 = shl i8 %16, 3
%26 = and i8 %25, -128
%27 = or i8 %24, %26
%28 = or i8 %27, 64
%29 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %28, i8* %29
%30 = lshr i8 %16, 5
%31 = getelementptr inbounds i8, i8* %13, i64 2
store i8 %30, i8* %31
%32 = lshr i8 %18, 3
%33 = or i8 %32, 1
%34 = getelementptr inbounds i8, i8* %13, i64 3
store i8 %33, i8* %34
%35 = lshr i8 %20, 1
%36 = and i8 %35, 120
%37 = or i8 %36, 4
%38 = getelementptr inbounds i8, i8* %13, i64 4
store i8 %37, i8* %38
%39 = getelementptr inbounds i8, i8* %12, i64 4
%40 = getelementptr inbounds i8, i8* %13, i64 5
%41 = add nuw nsw i32 %11, 1
%42 = icmp eq i32 %41, 50
br i1 %42, label %43, label %10
43: ; preds = %10
%44 = add nuw nsw i32 %6, 1
%45 = icmp eq i32 %44, 70
br i1 %45, label %46, label %5
46: ; preds = %43
%47 = getelementptr inbounds i8, i8* %1, i64 17642
%48 = tail call i32 @memcpy(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
ret void
}